Python matplotlib.rcsetup() Examples
The following are 5
code examples of matplotlib.rcsetup().
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: test_matplotlib.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_use_doc_standard_backends(): """ Test that the standard backends mentioned in the docstring of matplotlib.use() are the same as in matplotlib.rcsetup. """ def parse(key): backends = [] for line in matplotlib.use.__doc__.split(key)[1].split('\n'): if not line.strip(): break backends += [e.strip() for e in line.split(',') if e] return backends assert (set(parse('- interactive backends:\n')) == set(matplotlib.rcsetup.interactive_bk)) assert (set(parse('- non-interactive backends:\n')) == set(matplotlib.rcsetup.non_interactive_bk))
Example #2
Source File: test_matplotlib.py From coffeegrindsize with MIT License | 6 votes |
def test_use_doc_standard_backends(): """ Test that the standard backends mentioned in the docstring of matplotlib.use() are the same as in matplotlib.rcsetup. """ def parse(key): backends = [] for line in matplotlib.use.__doc__.split(key)[1].split('\n'): if not line.strip(): break backends += [e.strip() for e in line.split(',') if e] return backends assert (set(parse('- interactive backends:\n')) == set(matplotlib.rcsetup.interactive_bk)) assert (set(parse('- non-interactive backends:\n')) == set(matplotlib.rcsetup.non_interactive_bk))
Example #3
Source File: pyplot.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def switch_backend(newbackend): """ Close all open figures and set the Matplotlib backend. The argument is case-insensitive. Switching to an interactive backend is possible only if no event loop for another interactive backend has started. Switching to and from non-interactive backends is always possible. Parameters ---------- newbackend : str The name of the backend to use. """ close("all") if newbackend is rcsetup._auto_backend_sentinel: for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo", "tkagg", "wxagg", "agg", "cairo"]: try: switch_backend(candidate) except ImportError: continue else: rcParamsOrig['backend'] = candidate return backend_name = ( newbackend[9:] if newbackend.startswith("module://") else "matplotlib.backends.backend_{}".format(newbackend.lower())) backend_mod = importlib.import_module(backend_name) Backend = type( "Backend", (matplotlib.backends._Backend,), vars(backend_mod)) _log.debug("Loaded backend %s version %s.", newbackend, Backend.backend_version) required_framework = Backend.required_interactive_framework current_framework = \ matplotlib.backends._get_running_interactive_framework() if (current_framework and required_framework and current_framework != required_framework): raise ImportError( "Cannot load backend {!r} which requires the {!r} interactive " "framework, as {!r} is currently running".format( newbackend, required_framework, current_framework)) rcParams['backend'] = rcParamsDefault['backend'] = newbackend global _backend_mod, new_figure_manager, draw_if_interactive, _show _backend_mod = backend_mod new_figure_manager = Backend.new_figure_manager draw_if_interactive = Backend.draw_if_interactive _show = Backend.show # Need to keep a global reference to the backend for compatibility reasons. # See https://github.com/matplotlib/matplotlib/issues/6092 matplotlib.backends.backend = newbackend
Example #4
Source File: pyplot.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def switch_backend(newbackend): """ Close all open figures and set the Matplotlib backend. The argument is case-insensitive. Switching to an interactive backend is possible only if no event loop for another interactive backend has started. Switching to and from non-interactive backends is always possible. Parameters ---------- newbackend : str The name of the backend to use. """ close("all") if newbackend is rcsetup._auto_backend_sentinel: for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo", "tkagg", "wxagg", "agg", "cairo"]: try: switch_backend(candidate) except ImportError: continue else: rcParamsOrig['backend'] = candidate return backend_name = ( newbackend[9:] if newbackend.startswith("module://") else "matplotlib.backends.backend_{}".format(newbackend.lower())) backend_mod = importlib.import_module(backend_name) Backend = type( "Backend", (matplotlib.backends._Backend,), vars(backend_mod)) _log.debug("Loaded backend %s version %s.", newbackend, Backend.backend_version) required_framework = Backend.required_interactive_framework if required_framework is not None: current_framework = \ matplotlib.backends._get_running_interactive_framework() if (current_framework and required_framework and current_framework != required_framework): raise ImportError( "Cannot load backend {!r} which requires the {!r} interactive " "framework, as {!r} is currently running".format( newbackend, required_framework, current_framework)) rcParams['backend'] = rcParamsDefault['backend'] = newbackend global _backend_mod, new_figure_manager, draw_if_interactive, _show _backend_mod = backend_mod new_figure_manager = Backend.new_figure_manager draw_if_interactive = Backend.draw_if_interactive _show = Backend.show # Need to keep a global reference to the backend for compatibility reasons. # See https://github.com/matplotlib/matplotlib/issues/6092 matplotlib.backends.backend = newbackend
Example #5
Source File: pyplot.py From coffeegrindsize with MIT License | 4 votes |
def switch_backend(newbackend): """ Close all open figures and set the Matplotlib backend. The argument is case-insensitive. Switching to an interactive backend is possible only if no event loop for another interactive backend has started. Switching to and from non-interactive backends is always possible. Parameters ---------- newbackend : str The name of the backend to use. """ close("all") if newbackend is rcsetup._auto_backend_sentinel: for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo", "tkagg", "wxagg", "agg", "cairo"]: try: switch_backend(candidate) except ImportError: continue else: rcParamsOrig['backend'] = candidate return backend_name = ( newbackend[9:] if newbackend.startswith("module://") else "matplotlib.backends.backend_{}".format(newbackend.lower())) backend_mod = importlib.import_module(backend_name) Backend = type( "Backend", (matplotlib.backends._Backend,), vars(backend_mod)) _log.debug("Loaded backend %s version %s.", newbackend, Backend.backend_version) required_framework = Backend.required_interactive_framework if required_framework is not None: current_framework = \ matplotlib.backends._get_running_interactive_framework() if (current_framework and required_framework and current_framework != required_framework): raise ImportError( "Cannot load backend {!r} which requires the {!r} interactive " "framework, as {!r} is currently running".format( newbackend, required_framework, current_framework)) rcParams['backend'] = rcParamsDefault['backend'] = newbackend global _backend_mod, new_figure_manager, draw_if_interactive, _show _backend_mod = backend_mod new_figure_manager = Backend.new_figure_manager draw_if_interactive = Backend.draw_if_interactive _show = Backend.show # Need to keep a global reference to the backend for compatibility reasons. # See https://github.com/matplotlib/matplotlib/issues/6092 matplotlib.backends.backend = newbackend