本文整理匯總了Python中matplotlib.rcsetup方法的典型用法代碼示例。如果您正苦於以下問題:Python matplotlib.rcsetup方法的具體用法?Python matplotlib.rcsetup怎麽用?Python matplotlib.rcsetup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib
的用法示例。
在下文中一共展示了matplotlib.rcsetup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_use_doc_standard_backends
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcsetup [as 別名]
def test_use_doc_standard_backends():
"""
Test that the standard backends mentioned in the docstring of
matplotlib.use() are the same as in matplotlib.rcsetup.
"""
def parse(key):
backends = []
for line in matplotlib.use.__doc__.split(key)[1].split('\n'):
if not line.strip():
break
backends += [e.strip() for e in line.split(',') if e]
return backends
assert (set(parse('- interactive backends:\n')) ==
set(matplotlib.rcsetup.interactive_bk))
assert (set(parse('- non-interactive backends:\n')) ==
set(matplotlib.rcsetup.non_interactive_bk))
示例2: switch_backend
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcsetup [as 別名]
def switch_backend(newbackend):
"""
Close all open figures and set the Matplotlib backend.
The argument is case-insensitive. Switching to an interactive backend is
possible only if no event loop for another interactive backend has started.
Switching to and from non-interactive backends is always possible.
Parameters
----------
newbackend : str
The name of the backend to use.
"""
close("all")
if newbackend is rcsetup._auto_backend_sentinel:
for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo",
"tkagg", "wxagg", "agg", "cairo"]:
try:
switch_backend(candidate)
except ImportError:
continue
else:
rcParamsOrig['backend'] = candidate
return
backend_name = (
newbackend[9:] if newbackend.startswith("module://")
else "matplotlib.backends.backend_{}".format(newbackend.lower()))
backend_mod = importlib.import_module(backend_name)
Backend = type(
"Backend", (matplotlib.backends._Backend,), vars(backend_mod))
_log.debug("Loaded backend %s version %s.",
newbackend, Backend.backend_version)
required_framework = Backend.required_interactive_framework
current_framework = \
matplotlib.backends._get_running_interactive_framework()
if (current_framework and required_framework
and current_framework != required_framework):
raise ImportError(
"Cannot load backend {!r} which requires the {!r} interactive "
"framework, as {!r} is currently running".format(
newbackend, required_framework, current_framework))
rcParams['backend'] = rcParamsDefault['backend'] = newbackend
global _backend_mod, new_figure_manager, draw_if_interactive, _show
_backend_mod = backend_mod
new_figure_manager = Backend.new_figure_manager
draw_if_interactive = Backend.draw_if_interactive
_show = Backend.show
# Need to keep a global reference to the backend for compatibility reasons.
# See https://github.com/matplotlib/matplotlib/issues/6092
matplotlib.backends.backend = newbackend
示例3: switch_backend
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcsetup [as 別名]
def switch_backend(newbackend):
"""
Close all open figures and set the Matplotlib backend.
The argument is case-insensitive. Switching to an interactive backend is
possible only if no event loop for another interactive backend has started.
Switching to and from non-interactive backends is always possible.
Parameters
----------
newbackend : str
The name of the backend to use.
"""
close("all")
if newbackend is rcsetup._auto_backend_sentinel:
for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo",
"tkagg", "wxagg", "agg", "cairo"]:
try:
switch_backend(candidate)
except ImportError:
continue
else:
rcParamsOrig['backend'] = candidate
return
backend_name = (
newbackend[9:] if newbackend.startswith("module://")
else "matplotlib.backends.backend_{}".format(newbackend.lower()))
backend_mod = importlib.import_module(backend_name)
Backend = type(
"Backend", (matplotlib.backends._Backend,), vars(backend_mod))
_log.debug("Loaded backend %s version %s.",
newbackend, Backend.backend_version)
required_framework = Backend.required_interactive_framework
if required_framework is not None:
current_framework = \
matplotlib.backends._get_running_interactive_framework()
if (current_framework and required_framework
and current_framework != required_framework):
raise ImportError(
"Cannot load backend {!r} which requires the {!r} interactive "
"framework, as {!r} is currently running".format(
newbackend, required_framework, current_framework))
rcParams['backend'] = rcParamsDefault['backend'] = newbackend
global _backend_mod, new_figure_manager, draw_if_interactive, _show
_backend_mod = backend_mod
new_figure_manager = Backend.new_figure_manager
draw_if_interactive = Backend.draw_if_interactive
_show = Backend.show
# Need to keep a global reference to the backend for compatibility reasons.
# See https://github.com/matplotlib/matplotlib/issues/6092
matplotlib.backends.backend = newbackend