当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib.rcsetup方法代码示例

本文整理汇总了Python中matplotlib.rcsetup方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.rcsetup方法的具体用法?Python matplotlib.rcsetup怎么用?Python matplotlib.rcsetup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.rcsetup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_use_doc_standard_backends

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rcsetup [as 别名]
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)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:19,代码来源:test_matplotlib.py

示例2: switch_backend

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rcsetup [as 别名]
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 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:59,代码来源:pyplot.py

示例3: switch_backend

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rcsetup [as 别名]
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 
开发者ID:holzschu,项目名称:python3_ios,代码行数:60,代码来源:pyplot.py


注:本文中的matplotlib.rcsetup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。