Python matplotlib.rcdefaults() Examples
The following are 30
code examples of matplotlib.rcdefaults().
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 also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: core.py From neural-network-animation with 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
Source File: test_window.py From pytomo3d with 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 #3
Source File: core.py From ImageFusion with 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 #4
Source File: plot_style.py From threeML with 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 #5
Source File: __init__.py From python3_ios with 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 #6
Source File: __init__.py From GraphicDesignPatternByPython with 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 #7
Source File: __init__.py From coffeegrindsize with 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
Source File: __init__.py From CogAlg with 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
Source File: __init__.py From twitter-stock-recommendation with 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
Source File: core.py From coffeegrindsize with 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 #11
Source File: test_series.py From twitter-stock-recommendation with 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 #12
Source File: test_hist_method.py From twitter-stock-recommendation with 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 #13
Source File: test_backend_pgf.py From ImageFusion with 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 #14
Source File: test_misc.py From twitter-stock-recommendation with 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 #15
Source File: test_misc.py From elasticintel with GNU General Public License v3.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 #16
Source File: test_hist_method.py From elasticintel with GNU General Public License v3.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 #17
Source File: test_frame.py From elasticintel with GNU General Public License v3.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 #18
Source File: test_series.py From elasticintel with GNU General Public License v3.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 #19
Source File: pyplot.py From twitter-stock-recommendation with MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() if matplotlib.is_interactive(): draw_all() # The current "image" (ScalarMappable) is retrieved or set # only via the pyplot interface using the following two # functions:
Example #20
Source File: conftest.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def pytest_configure(config): builtins._pytest_running = True # do not assign to matplotlibrc_cache in function scope if HAS_MATPLOTLIB: with warnings.catch_warnings(): warnings.simplefilter('ignore') matplotlibrc_cache.update(matplotlib.rcParams) matplotlib.rcdefaults() # Make sure we use temporary directories for the config and cache # so that the tests are insensitive to local configuration. Note that this # is also set in the test runner, but we need to also set it here for # things to work properly in parallel mode builtins._xdg_config_home_orig = os.environ.get('XDG_CONFIG_HOME') builtins._xdg_cache_home_orig = os.environ.get('XDG_CACHE_HOME') os.environ['XDG_CONFIG_HOME'] = tempfile.mkdtemp('astropy_config') os.environ['XDG_CACHE_HOME'] = tempfile.mkdtemp('astropy_cache') os.mkdir(os.path.join(os.environ['XDG_CONFIG_HOME'], 'astropy')) os.mkdir(os.path.join(os.environ['XDG_CACHE_HOME'], 'astropy')) config.option.astropy_header = True PYTEST_HEADER_MODULES['Cython'] = 'cython' PYTEST_HEADER_MODULES['Scikit-image'] = 'skimage' PYTEST_HEADER_MODULES['asdf'] = 'asdf'
Example #21
Source File: pyplot.py From coffeegrindsize with MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() if matplotlib.is_interactive(): draw_all() ## Current image ##
Example #22
Source File: core.py From twitter-stock-recommendation with 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. """ initial_settings = mpl.rcParams.copy() if after_reset: mpl.rcdefaults() try: use(style) except: # Restore original settings before raising errors during the update. mpl.rcParams.update(initial_settings) raise else: yield finally: mpl.rcParams.update(initial_settings)
Example #23
Source File: test_misc.py From coffeegrindsize with 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 #24
Source File: test_hist_method.py From recruit with 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 #25
Source File: test_hist_method.py From coffeegrindsize with 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 #26
Source File: test_series.py From coffeegrindsize with 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 #27
Source File: common.py From coffeegrindsize with MIT License | 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 #28
Source File: core.py From CogAlg with 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 #29
Source File: pyplot.py From CogAlg with MIT License | 5 votes |
def rcdefaults(): matplotlib.rcdefaults() if matplotlib.is_interactive(): draw_all() ## Current image ##
Example #30
Source File: conftest.py From plotnine with GNU General Public License v2.0 | 5 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, 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") plt.switch_backend('Agg') # use Agg backend for these test if mpl.get_backend().lower() != "agg": msg = ("Using a wrong matplotlib backend ({0}), " "which will not produce proper images") raise Exception(msg.format(mpl.get_backend())) # These settings *must* be hardcoded for running the comparison # tests mpl.rcdefaults() # Start with all defaults mpl.rcParams['text.hinting'] = True mpl.rcParams['text.antialiased'] = True mpl.rcParams['text.hinting_factor'] = 8 # make sure we don't carry over bad plots from former tests msg = ("no of open figs: {} -> find the last test with ' " "python tests.py -v' and add a '@cleanup' decorator.") assert len(plt.get_fignums()) == 0, msg.format(plt.get_fignums())