Python matplotlib.rcsetup() Examples

The following are 5 code examples for showing how to use matplotlib.rcsetup(). 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: python3_ios   Author: holzschu   File: test_matplotlib.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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
Project: coffeegrindsize   Author: jgagneastro   File: test_matplotlib.py    License: MIT License 6 votes vote down vote up
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
Project: GraphicDesignPatternByPython   Author: Relph1119   File: pyplot.py    License: MIT License 4 votes vote down vote up
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
Project: python3_ios   Author: holzschu   File: pyplot.py    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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
Project: coffeegrindsize   Author: jgagneastro   File: pyplot.py    License: MIT License 4 votes vote down vote up
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