本文整理匯總了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)