本文整理汇总了Python中matplotlib.style.reload_library方法的典型用法代码示例。如果您正苦于以下问题:Python style.reload_library方法的具体用法?Python style.reload_library怎么用?Python style.reload_library使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.style
的用法示例。
在下文中一共展示了style.reload_library方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: temp_style
# 需要导入模块: from matplotlib import style [as 别名]
# 或者: from matplotlib.style import reload_library [as 别名]
def temp_style(style_name, settings=None):
"""Context manager to create a style sheet in a temporary directory."""
settings = DUMMY_SETTINGS
temp_file = '%s.%s' % (style_name, STYLE_EXTENSION)
# Write style settings to file in the temp directory.
tempdir = tempfile.mkdtemp()
with open(os.path.join(tempdir, temp_file), 'w') as f:
for k, v in six.iteritems(settings):
f.write('%s: %s' % (k, v))
# Add temp directory to style path and reload so we can access this style.
USER_LIBRARY_PATHS.append(tempdir)
style.reload_library()
try:
yield
finally:
shutil.rmtree(tempdir)
style.reload_library()
示例2: temp_style
# 需要导入模块: from matplotlib import style [as 别名]
# 或者: from matplotlib.style import reload_library [as 别名]
def temp_style(style_name, settings=None):
"""Context manager to create a style sheet in a temporary directory."""
if not settings:
settings = DUMMY_SETTINGS
temp_file = '%s.%s' % (style_name, STYLE_EXTENSION)
try:
with TemporaryDirectory() as tmpdir:
# Write style settings to file in the tmpdir.
Path(tmpdir, temp_file).write_text(
"\n".join("{}: {}".format(k, v) for k, v in settings.items()))
# Add tmpdir to style path and reload so we can access this style.
USER_LIBRARY_PATHS.append(tmpdir)
style.reload_library()
yield
finally:
style.reload_library()
示例3: temp_style
# 需要导入模块: from matplotlib import style [as 别名]
# 或者: from matplotlib.style import reload_library [as 别名]
def temp_style(style_name, settings=None):
"""Context manager to create a style sheet in a temporary directory."""
if not settings:
settings = DUMMY_SETTINGS
temp_file = '%s.%s' % (style_name, STYLE_EXTENSION)
# Write style settings to file in the temp directory.
tempdir = tempfile.mkdtemp()
with open(os.path.join(tempdir, temp_file), 'w') as f:
for k, v in six.iteritems(settings):
f.write('%s: %s' % (k, v))
# Add temp directory to style path and reload so we can access this style.
USER_LIBRARY_PATHS.append(tempdir)
style.reload_library()
try:
yield
finally:
shutil.rmtree(tempdir)
style.reload_library()
示例4: test_invalid_rc_warning_includes_filename
# 需要导入模块: from matplotlib import style [as 别名]
# 或者: from matplotlib.style import reload_library [as 别名]
def test_invalid_rc_warning_includes_filename():
SETTINGS = {'foo': 'bar'}
basename = 'basename'
with warnings.catch_warnings(record=True) as warns:
with temp_style(basename, SETTINGS):
# style.reload_library() in temp_style() triggers the warning
pass
for w in warns:
assert basename in str(w.message)