Python matplotlib.rcdefaults() Examples
The following are 30 code examples for showing how to use matplotlib.rcdefaults(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: neural-network-animation Author: miloharper File: core.py License: MIT License | 6 votes |
def context(name, after_reset=False): """Context manager for using style settings temporarily. Parameters ---------- name : str or list of str Name of style or path/URL to a style file. For a list of available style names, see `style.available`. If given a list, each style is applied from first to last in the list. after_reset : bool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. """ initial_settings = mpl.rcParams.copy() if after_reset: mpl.rcdefaults() use(name) yield mpl.rcParams.update(initial_settings)
Example 2
Project: GraphicDesignPatternByPython Author: Relph1119 File: __init__.py License: MIT License | 6 votes |
def setup(): # The baseline images are created in this locale, so we should use # it during all of the tests. try: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') except locale.Error: try: locale.setlocale(locale.LC_ALL, 'English_United States.1252') except locale.Error: warnings.warn( "Could not set locale to English/United States. " "Some date-related tests may fail.") mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests with warnings.catch_warnings(): warnings.simplefilter("ignore", MatplotlibDeprecationWarning) mpl.rcdefaults() # Start with all defaults # These settings *must* be hardcoded for running the comparison tests and # are not necessarily the default values as specified in rcsetup.py. set_font_settings_for_testing() set_reproducibility_for_testing()
Example 3
Project: python3_ios Author: holzschu File: __init__.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def setup(): # The baseline images are created in this locale, so we should use # it during all of the tests. try: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') except locale.Error: try: locale.setlocale(locale.LC_ALL, 'English_United States.1252') except locale.Error: warnings.warn( "Could not set locale to English/United States. " "Some date-related tests may fail.") mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests with warnings.catch_warnings(): warnings.simplefilter("ignore", MatplotlibDeprecationWarning) mpl.rcdefaults() # Start with all defaults # These settings *must* be hardcoded for running the comparison tests and # are not necessarily the default values as specified in rcsetup.py. set_font_settings_for_testing() set_reproducibility_for_testing()
Example 4
Project: pytomo3d Author: computational-seismology File: test_window.py License: GNU Lesser General Public License v3.0 | 6 votes |
def reset_matplotlib(): """ Reset matplotlib to a common default. """ # Set all default values. mpl.rcdefaults() # Force agg backend. plt.switch_backend('agg') # These settings must be hardcoded for running the comparision tests and # are not necessarily the default values. mpl.rcParams['font.family'] = 'Bitstream Vera Sans' mpl.rcParams['text.hinting'] = False # Not available for all matplotlib versions. try: mpl.rcParams['text.hinting_factor'] = 8 except KeyError: pass import locale locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) # Most generic way to get the data folder path.
Example 5
Project: ImageFusion Author: pfchai File: core.py License: MIT License | 6 votes |
def context(name, after_reset=False): """Context manager for using style settings temporarily. Parameters ---------- name : str or list of str Name of style or path/URL to a style file. For a list of available style names, see `style.available`. If given a list, each style is applied from first to last in the list. after_reset : bool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. """ initial_settings = mpl.rcParams.copy() if after_reset: mpl.rcdefaults() use(name) yield mpl.rcParams.update(initial_settings)
Example 6
Project: threeML Author: threeML File: plot_style.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def deactivate(): """ Deactivate the current style and restore the default. Do not use this directly. Use the `with plot_style([style name])` context manager instead. :return: None """ # Restore matplotlib defaults mpl.rcdefaults() # Restore 3ML default global current_style current_style = defined_styles["default"]
Example 7
Project: coffeegrindsize Author: jgagneastro File: __init__.py License: MIT License | 6 votes |
def setup(): # The baseline images are created in this locale, so we should use # it during all of the tests. try: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') except locale.Error: try: locale.setlocale(locale.LC_ALL, 'English_United States.1252') except locale.Error: warnings.warn( "Could not set locale to English/United States. " "Some date-related tests may fail.") mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests with warnings.catch_warnings(): warnings.simplefilter("ignore", MatplotlibDeprecationWarning) mpl.rcdefaults() # Start with all defaults # These settings *must* be hardcoded for running the comparison tests and # are not necessarily the default values as specified in rcsetup.py. set_font_settings_for_testing() set_reproducibility_for_testing()
Example 8
Project: CogAlg Author: boris-kz File: __init__.py License: MIT License | 6 votes |
def setup(): # The baseline images are created in this locale, so we should use # it during all of the tests. try: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') except locale.Error: try: locale.setlocale(locale.LC_ALL, 'English_United States.1252') except locale.Error: _log.warning( "Could not set locale to English/United States. " "Some date-related tests may fail.") mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests with cbook._suppress_matplotlib_deprecation_warning(): mpl.rcdefaults() # Start with all defaults # These settings *must* be hardcoded for running the comparison tests and # are not necessarily the default values as specified in rcsetup.py. set_font_settings_for_testing() set_reproducibility_for_testing()
Example 9
Project: twitter-stock-recommendation Author: alvarobartt File: __init__.py License: MIT License | 6 votes |
def setup(): # The baseline images are created in this locale, so we should use # it during all of the tests. import locale from matplotlib.backends import backend_agg, backend_pdf, backend_svg try: locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) except locale.Error: try: locale.setlocale(locale.LC_ALL, str('English_United States.1252')) except locale.Error: warnings.warn( "Could not set locale to English/United States. " "Some date-related tests may fail") mpl.use('Agg', warn=False) # use Agg backend for these tests # These settings *must* be hardcoded for running the comparison # tests and are not necessarily the default values as specified in # rcsetup.py mpl.rcdefaults() # Start with all defaults set_font_settings_for_testing() set_reproducibility_for_testing()
Example 10
Project: recruit Author: Frank-qlu File: test_misc.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'
Example 11
Project: recruit Author: Frank-qlu File: test_hist_method.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'
Example 12
Project: recruit Author: Frank-qlu File: test_frame.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.tdf = tm.makeTimeDataFrame() self.hexbin_df = DataFrame({"A": np.random.uniform(size=20), "B": np.random.uniform(size=20), "C": np.arange(20) + np.random.uniform( size=20)})
Example 13
Project: recruit Author: Frank-qlu File: test_series.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts' self.series = tm.makeStringSeries() self.series.name = 'series' self.iseries = tm.makePeriodSeries() self.iseries.name = 'iseries'
Example 14
Project: recruit Author: Frank-qlu File: common.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): import matplotlib as mpl mpl.rcdefaults() self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1() self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0() self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0() self.mpl_ge_2_2_2 = plotting._compat._mpl_ge_2_2_2() self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0() self.bp_n_objects = 7 self.polycollection_factor = 2 self.default_figsize = (6.4, 4.8) self.default_tick_position = 'left' n = 100 with tm.RNGContext(42): gender = np.random.choice(['Male', 'Female'], size=n) classroom = np.random.choice(['A', 'B', 'C'], size=n) self.hist_df = DataFrame({'gender': gender, 'classroom': classroom, 'height': random.normal(66, 4, size=n), 'weight': random.normal(161, 32, size=n), 'category': random.randint(4, size=n)}) self.tdf = tm.makeTimeDataFrame() self.hexbin_df = DataFrame({"A": np.random.uniform(size=20), "B": np.random.uniform(size=20), "C": np.arange(20) + np.random.uniform( size=20)})
Example 15
Project: ehtplot Author: liamedeiros File: figure.py License: GNU General Public License v3.0 | 5 votes |
def __call__(self, **kwargs): """Figure realizer The Figure class only keeps track of a root panel. It does not contain an actual matplotlib Figure instance. Whenever a figure needs to be created, Figure creates a new matplotlib Figure in order to drew/rendered/realized the figure. Args: **kwargs (dict): Arbitrary Figure-specific keyworded arguments that are used to construct the matplotlib Figure. """ kwprops = merge_dict(self.kwprops, kwargs) style = kwprops.pop('style') with mpl.rc_context(): mpl.rcdefaults() plt.style.use(style) imode = mpl.is_interactive() if imode: plt.ioff() fig = plt.figure(**kwprops) ax = newaxes(fig) yield fig, ax if imode: plt.ion()
Example 16
Project: vnpy_crypto Author: birforce File: test_misc.py License: MIT License | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'
Example 17
Project: vnpy_crypto Author: birforce File: test_hist_method.py License: MIT License | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'
Example 18
Project: vnpy_crypto Author: birforce File: test_frame.py License: MIT License | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.tdf = tm.makeTimeDataFrame() self.hexbin_df = DataFrame({"A": np.random.uniform(size=20), "B": np.random.uniform(size=20), "C": np.arange(20) + np.random.uniform( size=20)})
Example 19
Project: vnpy_crypto Author: birforce File: test_series.py License: MIT License | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts' self.series = tm.makeStringSeries() self.series.name = 'series' self.iseries = tm.makePeriodSeries() self.iseries.name = 'iseries'
Example 20
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() draw_if_interactive() # The current "image" (ScalarMappable) is retrieved or set # only via the pyplot interface using the following two # functions:
Example 21
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: core.py License: MIT License | 5 votes |
def context(style, after_reset=False): """Context manager for using style settings temporarily. Parameters ---------- style : str, dict, or list A style specification. Valid options are: +------+-------------------------------------------------------------+ | str | The name of a style or a path/URL to a style file. For a | | | list of available style names, see `style.available`. | +------+-------------------------------------------------------------+ | dict | Dictionary with valid key/value pairs for | | | `matplotlib.rcParams`. | +------+-------------------------------------------------------------+ | list | A list of style specifiers (str or dict) applied from first | | | to last in the list. | +------+-------------------------------------------------------------+ after_reset : bool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. """ with mpl.rc_context(): if after_reset: mpl.rcdefaults() use(style) yield
Example 22
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() draw_if_interactive() # The current "image" (ScalarMappable) is retrieved or set # only via the pyplot interface using the following two # functions:
Example 23
Project: neural-network-animation Author: miloharper File: test_backend_pgf.py License: MIT License | 5 votes |
def switch_backend(backend): def switch_backend_decorator(func): def backend_switcher(*args, **kwargs): try: prev_backend = mpl.get_backend() mpl.rcdefaults() plt.switch_backend(backend) result = func(*args, **kwargs) finally: plt.switch_backend(prev_backend) return result return nose.tools.make_decorator(func)(backend_switcher) return switch_backend_decorator
Example 24
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() draw_if_interactive() # The current "image" (ScalarMappable) is retrieved or set # only via the pyplot interface using the following two # functions:
Example 25
Project: GraphicDesignPatternByPython Author: Relph1119 File: core.py License: MIT License | 5 votes |
def context(style, after_reset=False): """Context manager for using style settings temporarily. Parameters ---------- style : str, dict, or list A style specification. Valid options are: +------+-------------------------------------------------------------+ | str | The name of a style or a path/URL to a style file. For a | | | list of available style names, see `style.available`. | +------+-------------------------------------------------------------+ | dict | Dictionary with valid key/value pairs for | | | `matplotlib.rcParams`. | +------+-------------------------------------------------------------+ | list | A list of style specifiers (str or dict) applied from first | | | to last in the list. | +------+-------------------------------------------------------------+ after_reset : bool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. """ with mpl.rc_context(): if after_reset: mpl.rcdefaults() use(style) yield
Example 26
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() if matplotlib.is_interactive(): draw_all() ## Current image ##
Example 27
Project: python3_ios Author: holzschu File: core.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def context(style, after_reset=False): """Context manager for using style settings temporarily. Parameters ---------- style : str, dict, or list A style specification. Valid options are: +------+-------------------------------------------------------------+ | str | The name of a style or a path/URL to a style file. For a | | | list of available style names, see `style.available`. | +------+-------------------------------------------------------------+ | dict | Dictionary with valid key/value pairs for | | | `matplotlib.rcParams`. | +------+-------------------------------------------------------------+ | list | A list of style specifiers (str or dict) applied from first | | | to last in the list. | +------+-------------------------------------------------------------+ after_reset : bool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. """ with mpl.rc_context(): if after_reset: mpl.rcdefaults() use(style) yield
Example 28
Project: python3_ios Author: holzschu File: pyplot.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() if matplotlib.is_interactive(): draw_all() ## Current image ##
Example 29
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_misc.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'
Example 30
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_hist_method.py License: Apache License 2.0 | 5 votes |
def setup_method(self, method): TestPlotBase.setup_method(self, method) import matplotlib as mpl mpl.rcdefaults() self.ts = tm.makeTimeSeries() self.ts.name = 'ts'