本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __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
"""
if matplotlib_defaults:
self._rcParams.update(mpl.rcParams)
if fname:
self._rcParams.update(mpl.rc_params_from_file(fname))
if rc:
self._rcParams.update(rc)
开发者ID:andrewflowers,项目名称:ggplot,代码行数:18,代码来源:theme_matplotlib.py
示例17: set_style
def set_style(key):
"""
Select a style by name, e.g. set_style('default'). To revert to the
previous style use the key 'unset' or False.
"""
if key is None:
return
elif not key or key in ['unset', 'backup']:
if 'backup' in styles:
plt.rcParams.update(styles['backup'])
else:
raise Exception('No style backed up to restore')
elif key not in styles:
raise KeyError('%r not in available styles.')
else:
path = os.path.join(os.path.dirname(__file__), styles[key])
new_style = rc_params_from_file(path)
styles['backup'] = dict(plt.rcParams)
plt.rcParams.update(new_style)
开发者ID:james-isbister,项目名称:holoviews,代码行数:20,代码来源:__init__.py
示例18: get_styles
def get_styles():
'''Return 2 random rcParams styles'''
files = glob('params/*')
random.shuffle(files)
styles = []
used_default = False
for f in files[:2]:
this_rc = rcParamsDefault.copy()
if os.path.splitext(f)[1] == '.json':
s = json.load(open(f))
else:
s = rc_params_from_file(f)
this_rc.update(s)
#with some probability, use default
if random.random() > .9 and not used_default:
this_rc = rcParamsDefault.copy()
used_default = True
styles.append(this_rc)
return styles
开发者ID:ChrisBeaumont,项目名称:plotornot,代码行数:24,代码来源:app.py
示例19: enumerate
#! /usr/bin/env python
# -*- coding: utf-8 -*-
## plotting script for F-I analysis of single cell.
## Usage: pythonv fi_plot.py b1415721979.9
import sys
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import seaborn as sns
rc = matplotlib.rc_params_from_file('/home/ucbtepi/thesis/matplotlibrc.thesis',
use_default_template=False)
matplotlib.rcParams.update(rc)
figsize = (1.75,1.25) # (3.5,3) for full-size figure
timestamp = sys.argv[1]
current_amplitude_range = np.arange(-25000, 500, 500) # (fA) # np.array([-25.e3, -20.e3, -15.e3, -10.e3, -5.e3, 0., 50.e3, 100.e3, 150.e3, 200.e3, 250.e3])
sim_duration = 6000. #(ms)
transient = 1000. #(ms)
colors = ['k', 'r', 'g']
fig, ax = plt.subplots(figsize=figsize)
for k, cell_name in enumerate(['Solinas', 'Vervaeke', 'reduced']):
data = []
threshold = 'min20'
for amplitude in current_amplitude_range:
filename = '../simulations/{0}_{1:.0f}/Golgi_{2}_0.SPIKES_{3}.spike'.format(timestamp,
amplitude,
开发者ID:RokasSt,项目名称:GJGolgi_ReducedMorph,代码行数:31,代码来源:fi_plot.py
示例20: 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):
styles[name] = rc_params_from_file(path, use_default_template=False)
return styles
开发者ID:Kojoley,项目名称:matplotlib,代码行数:6,代码来源:core.py
注:本文中的matplotlib.rc_params_from_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论