本文整理匯總了Python中matplotlib.rcParamsDefault方法的典型用法代碼示例。如果您正苦於以下問題:Python matplotlib.rcParamsDefault方法的具體用法?Python matplotlib.rcParamsDefault怎麽用?Python matplotlib.rcParamsDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib
的用法示例。
在下文中一共展示了matplotlib.rcParamsDefault方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: format_axes
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def format_axes(ax):
for spine in ['top', 'right']:
ax.spines[spine].set_visible(False)
for spine in ['left', 'bottom']:
ax.spines[spine].set_color(SPINE_COLOR)
ax.spines[spine].set_linewidth(0.5)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
for axis in [ax.xaxis, ax.yaxis]:
axis.set_tick_params(direction='out', color=SPINE_COLOR)
return ax
# mpl.rcParams.update(mpl.rcParamsDefault)
示例2: _init_from_registry
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def _init_from_registry(cls):
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
return
import winreg
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
try:
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
r'Software\Imagemagick\Current',
0, winreg.KEY_QUERY_VALUE | flag)
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
winreg.CloseKey(hkey)
break
except Exception:
binpath = ''
if binpath:
for exe in ('convert.exe', 'magick.exe'):
path = os.path.join(binpath, exe)
if os.path.exists(path):
binpath = path
break
else:
binpath = ''
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
示例3: _init_from_registry
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def _init_from_registry(cls):
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
return
from six.moves import winreg
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
try:
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
'Software\\Imagemagick\\Current',
0, winreg.KEY_QUERY_VALUE | flag)
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
winreg.CloseKey(hkey)
binpath += '\\convert.exe'
break
except Exception:
binpath = ''
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
示例4: set_rcParams_defaults
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def set_rcParams_defaults():
"""Reset `matplotlib.rcParams` to defaults."""
rcParams.update(matplotlib.rcParamsDefault)
示例5: reset_defaults
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def reset_defaults():
"""Restore all RC params to default settings."""
mpl.rcParams.update(mpl.rcParamsDefault)
示例6: set_rcParams_defaults
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def set_rcParams_defaults():
"""Reset `matplotlib.rcParams` to defaults."""
from matplotlib import rcParamsDefault
rcParams.update(rcParamsDefault)
# ------------------------------------------------------------------------------
# Private global variables & functions
# ------------------------------------------------------------------------------
示例7: reset_rcParams
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
def reset_rcParams():
"""Reset `matplotlib.rcParams` to defaults."""
from matplotlib import rcParamsDefault
rcParams.update(rcParamsDefault)
示例8: use
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
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 cbook._suppress_matplotlib_deprecation_warning():
_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))
示例9: use
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
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))
示例10: switch_backend
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [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
示例11: switch_backend
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [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
示例12: use
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import rcParamsDefault [as 別名]
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:
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))