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


Python matplotlib.rc_params_from_file函数代码示例

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


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

示例1: test_if_rctemplate_would_be_valid

def test_if_rctemplate_would_be_valid(tmpdir):
    # This tests if the matplotlibrc.template file would result in a valid
    # rc file if all lines are uncommented.
    path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
    with open(path_to_rc, "r") as f:
        rclines = f.readlines()
    newlines = []
    for line in rclines:
        if line[0] == "#":
            newline = line[1:]
        else:
            newline = line
        if "$TEMPLATE_BACKEND" in newline:
            newline = "backend : Agg"
        if "datapath" in newline:
            newline = ""
        newlines.append(newline)
    d = tmpdir.mkdir('test1')
    fname = str(d.join('testrcvalid.temp'))
    with open(fname, "w") as f:
        f.writelines(newlines)
    with pytest.warns(None) as record:
        mpl.rc_params_from_file(fname,
                                fail_on_error=True,
                                use_default_template=False)
        assert len(record) == 0
开发者ID:jklymak,项目名称:matplotlib,代码行数:26,代码来源:test_rcparams.py

示例2: test_Issue_1713

def test_Issue_1713():
    utf32_be = os.path.join(os.path.dirname(__file__),
                           'test_utf32_be_rcparams.rc')
    import locale
    with mock.patch('locale.getpreferredencoding', return_value='UTF-32-BE'):
        rc = mpl.rc_params_from_file(utf32_be, True, False)
    assert rc.get('timezone') == 'UTC'
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:7,代码来源:test_rcparams.py

示例3: __init__

 def __init__(self, rc=None, fname=None,  matplotlib_defaults=True):
     """Initialize the theme
     
     Parameters
     -----------
     rc:  dict of rcParams
         rcParams which should be aplied on top of mathplotlib default
     fname:  Filename (str)
         a filename to a matplotlibrc file  
     matplotlib_defaults: bool
         if True resets the plot setting to the (current) 
         matplotlib.rcParams values
     """
     self._rcParams={}
     if matplotlib_defaults:
         _copy = mpl.rcParams.copy()
         # no need to a get a deprecate warning just because they are still included in 
         # rcParams...
         for key in mpl._deprecated_map:
             if key in _copy:
                 del _copy[key]
         if 'tk.pythoninspect' in _copy:
             del _copy['tk.pythoninspect']
         self._rcParams.update(_copy)
     if fname:
         self._rcParams.update(mpl.rc_params_from_file(fname))
     if rc:
         self._rcParams.update(rc)
开发者ID:bnmnetp,项目名称:ggplot,代码行数:28,代码来源:theme_matplotlib.py

示例4: __init__

    def __init__(self, rc=None, fname=None, use_defaults=True):
        theme.__init__(
            self,
            aspect_ratio=get_option('aspect_ratio'),
            dpi=get_option('dpi'),
            figure_size=get_option('figure_size'),
            legend_key=element_rect(fill='None', colour='None'),
            panel_spacing=0.1,
            strip_background=element_rect(
                fill='#D9D9D9', color='#D9D9D9', size=1),
            complete=True)

        if use_defaults:
            _copy = mpl.rcParams.copy()
            # no need to a get a deprecate warning just because
            # they are still included in rcParams...
            for key in mpl._deprecated_map:
                if key in _copy:
                    del _copy[key]
            if 'tk.pythoninspect' in _copy:
                del _copy['tk.pythoninspect']
            self._rcParams.update(_copy)

        if fname:
            self._rcParams.update(mpl.rc_params_from_file(fname))
        if rc:
            self._rcParams.update(rc)
开发者ID:jwhendy,项目名称:plotnine,代码行数:27,代码来源:theme_matplotlib.py

示例5: use

def use(name):
    """Use matplotlib style settings from a known style sheet or from a file.

    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.
    """
    if cbook.is_string_like(name):
        name = [name]

    for style in name:
        if style in library:
            mpl.rcParams.update(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                mpl.rcParams.update(rc)
            except:
                msg = ("'%s' not found in the style library and input is "
                       "not a valid URL or path. See `style.available` for "
                       "list of available styles.")
                raise ValueError(msg % style)
开发者ID:AudiencePropensities,项目名称:matplotlib,代码行数:25,代码来源:core.py

示例6: stylely

def stylely(rc_dict={}, style_file = 'skrf.mplstyle'):
    '''
    loads the rc-params from the specified file (file must be located in skrf/data)
    '''

    from skrf.data import pwd # delayed to solve circular import
    rc = mpl.rc_params_from_file(os.path.join(pwd, style_file))
    mpl.rcParams.update(rc)
    mpl.rcParams.update(rc_dict)
开发者ID:dylanbespalko,项目名称:scikit-rf,代码行数:9,代码来源:util.py

示例7: stylely

def stylely(rc_dict={}):
    '''
    loads the rc-params file from skrf.data 
    '''
    
    from skrf.data import mpl_rc_fname # delayed to solve circular import
    rc = mpl.rc_params_from_file(mpl_rc_fname)
    mpl.rcParams.update(rc)
    mpl.rcParams.update(rc_dict)
开发者ID:buguen,项目名称:scikit-rf,代码行数:9,代码来源:util.py

示例8: test_Issue_1713

def test_Issue_1713():
    utf32_be = os.path.join(os.path.dirname(__file__), "test_utf32_be_rcparams.rc")
    old_lang = os.environ.get("LANG", None)
    os.environ["LANG"] = "en_US.UTF-32-BE"
    rc = mpl.rc_params_from_file(utf32_be, True)
    if old_lang:
        os.environ["LANG"] = old_lang
    else:
        del os.environ["LANG"]
    assert rc.get("timezone") == "UTC"
开发者ID:rmorshea,项目名称:matplotlib,代码行数:10,代码来源:test_rcparams.py

示例9: load_matplotlib_style

def load_matplotlib_style(name="default"):
    # loading customized matplotlib style. If not available, it does nothing
    try:
        if name == "default":
            mpl.rcParams = mpl.rc_params_from_file(module_dir + "/matplotlibrc")
        reload(plt)
        # reload(gridspec)
    except:
        print exc_info()
        pass
开发者ID:leosala,项目名称:photon_tools,代码行数:10,代码来源:plot_utilities.py

示例10: use

def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    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.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style))
开发者ID:dopplershift,项目名称:matplotlib,代码行数:54,代码来源:core.py

示例11: test_Issue_1713

def test_Issue_1713():
    utf32_be = os.path.join(os.path.dirname(__file__),
                           'test_utf32_be_rcparams.rc')
    old_lang = os.environ.get('LANG', None)
    os.environ['LANG'] = 'en_US.UTF-32-BE'
    rc = mpl.rc_params_from_file(utf32_be, True)
    if old_lang:
        os.environ['LANG'] = old_lang
    else:
        del os.environ['LANG']
    assert rc.get('timezone') == 'UTC'
开发者ID:7924102,项目名称:matplotlib,代码行数:11,代码来源:test_rcparams.py

示例12: use

def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    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.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, six.string_types) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s)
              if isinstance(s, six.string_types)
              else s
              for s in styles)
    for style in styles:
        if not isinstance(style, six.string_types):
            _apply_style(style)
        elif style == 'default':
            _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                msg = ("'%s' not found in the style library and input is "
                       "not a valid URL or path. See `style.available` for "
                       "list of available styles.")
                raise IOError(msg % style)
开发者ID:Eric89GXL,项目名称:matplotlib,代码行数:52,代码来源:core.py

示例13: read_style_directory

def read_style_directory(style_dir):
    """Return dictionary of styles defined in `style_dir`."""
    styles = dict()
    for path, name in iter_style_files(style_dir):
        with warnings.catch_warnings(record=True) as warns:
            styles[name] = rc_params_from_file(path,
                                               use_default_template=False)

        for w in warns:
            message = 'In %s: %s' % (path, w.message)
            warnings.warn(message, stacklevel=2)

    return styles
开发者ID:dopplershift,项目名称:matplotlib,代码行数:13,代码来源:core.py

示例14: use

def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    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.                                        |
        +------+-------------------------------------------------------------+


    """
    if cbook.is_string_like(style) or hasattr(style, "keys"):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    for style in styles:
        if not cbook.is_string_like(style):
            mpl.rcParams.update(style)
            continue
        elif style == "default":
            mpl.rcdefaults()
            continue

        if style in library:
            mpl.rcParams.update(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                mpl.rcParams.update(rc)
            except IOError:
                msg = (
                    "'%s' not found in the style library and input is "
                    "not a valid URL or path. See `style.available` for "
                    "list of available styles."
                )
                raise IOError(msg % style)
开发者ID:KevKeating,项目名称:matplotlib,代码行数:51,代码来源:core.py

示例15: __init__

 def __init__(self, rc=None, fname=None,  matplotlib_defaults=True):
     self._rcParams={}
     if matplotlib_defaults:
         _copy = mpl.rcParams.copy()
         # no need to a get a deprecate warning just because they are still included in 
         # rcParams...
         for key in mpl._deprecated_map:
             if key in _copy:
                 del _copy[key]
         if 'tk.pythoninspect' in _copy:
             del _copy['tk.pythoninspect']
         self._rcParams.update(_copy)
     if fname:
         self._rcParams.update(mpl.rc_params_from_file(fname))
     if rc:
         self._rcParams.update(rc)
开发者ID:GarnetVaz,项目名称:ggplot,代码行数:16,代码来源:theme_matplotlib.py


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