• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python rcsetup.validate_backend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: use

def use(arg, warn=True):
    """
    Set the matplotlib backend to one of the known backends.

    The argument is case-insensitive.

    .. note::

        This function must be called *before* importing pyplot for
        the first time; or, if you are not using pyplot, it must be called
        before importing matplotlib.backends.  If warn is True, a warning
        is issued if you try and call this after pylab or pyplot have been
        loaded.  In certain black magic use cases, e.g.
        :func:`pyplot.switch_backends`, we are doing the reloading necessary to
        make the backend switch work (in some cases, e.g. pure image
        backends) so one can set warn=False to supporess the warnings.

    To find out which backend is currently set, see
    :func:`matplotlib.get_backend`.

    """
    if 'matplotlib.backends' in sys.modules:
        if warn: warnings.warn(_use_error_msg)
        return
    if arg.startswith('module://'):
        name = arg
    else:
        # Lowercase only non-module backend names (modules are case-sensitive)
        arg = arg.lower()
        name = validate_backend(arg)
    rcParams['backend'] = name
开发者ID:idealisms,项目名称:matplotlib,代码行数:31,代码来源:__init__.py


示例2: use

def use(arg, warn=True, force=False):
    """
    Set the matplotlib backend to one of the known backends.

    The argument is case-insensitive. *warn* specifies whether a
    warning should be issued if a backend has already been set up.
    *force* is an **experimental** flag that tells matplotlib to
    attempt to initialize a new backend by reloading the backend
    module.

    .. note::

        This function must be called *before* importing pyplot for
        the first time; or, if you are not using pyplot, it must be called
        before importing matplotlib.backends.  If warn is True, a warning
        is issued if you try and call this after pylab or pyplot have been
        loaded.  In certain black magic use cases, e.g.
        :func:`pyplot.switch_backend`, we are doing the reloading necessary to
        make the backend switch work (in some cases, e.g., pure image
        backends) so one can set warn=False to suppress the warnings.

    To find out which backend is currently set, see
    :func:`matplotlib.get_backend`.

    """
    # Lets determine the proper backend name first
    if arg.startswith('module://'):
        name = arg
    else:
        # Lowercase only non-module backend names (modules are case-sensitive)
        arg = arg.lower()
        name = validate_backend(arg)

    # Check if we've already set up a backend
    if 'matplotlib.backends' in sys.modules:
        # Warn only if called with a different name
        if (rcParams['backend'] != name) and warn:
            warnings.warn(_use_error_msg)

        # Unless we've been told to force it, just return
        if not force:
            return
        need_reload = True
    else:
        need_reload = False

    # Store the backend name
    rcParams['backend'] = name

    # If needed we reload here because a lot of setup code is triggered on
    # module import. See backends/__init__.py for more detail.
    if need_reload:
        reload(sys.modules['matplotlib.backends'])
开发者ID:JamesMakela,项目名称:matplotlib,代码行数:53,代码来源:__init__.py


示例3: use

def use(arg, warn=True):
    """
    Set the matplotlib backend to one of the known backends.

    The argument is case-insensitive.  For the Cairo backend,
    the argument can have an extension to indicate the type of
    output.  Example:

        use('cairo.pdf')

    will specify a default of pdf output generated by Cairo.

    .. note::

        This function must be called *before* importing pyplot for
        the first time; or, if you are not using pyplot, it must be called
        before importing matplotlib.backends.  If warn is True, a warning
        is issued if you try and call this after pylab or pyplot have been
        loaded.  In certain black magic use cases, e.g.
        :func:`pyplot.switch_backends`, we are doing the reloading necessary to
        make the backend switch work (in some cases, e.g. pure image
        backends) so one can set warn=False to supporess the warnings.

    To find out which backend is currently set, see
    :func:`matplotlib.get_backend`.

    """
    if 'matplotlib.backends' in sys.modules:
        if warn: warnings.warn(_use_error_msg)
        return
    if arg.startswith('module://'):
        name = arg
    else:
        # Lowercase only non-module backend names (modules are case-sensitive)
        arg = arg.lower()
        be_parts = arg.split('.')
        name = validate_backend(be_parts[0])
        if len(be_parts) > 1:
            if name == 'cairo':
                rcParams['cairo.format'] = validate_cairo_format(be_parts[1])
            else:
                raise ValueError('Only cairo backend has a format option')
    rcParams['backend'] = name
开发者ID:EnochManohar,项目名称:matplotlib,代码行数:43,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python defaultParams.iteritems函数代码示例发布时间:2022-05-27
下一篇:
Python rcParams.update函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap