Matplotlib is hiring a Research Software Engineering Fellow! See discourse for details. Apply by January 3, 2020
matplotlib.
use
(arg, warn=False, force=True)[源代码]¶将matplotlib后端设置为已知后端之一。
参数: |
|
---|
matplotlib.
rc_context
(rc=None, fname=None)[源代码]¶返回用于管理RC设置的上下文管理器。
这样就可以做到:
with mpl.rc_context(fname='screen.rc'):
plt.plot(x, a)
with mpl.rc_context(fname='print.rc'):
plt.plot(x, b)
plt.plot(x, c)
“a”与“x”和“c”与“x”绘图将具有“screen.rc”中的设置,“b”与“x”绘图将具有“print.rc”中的设置。
字典也可以传递给上下文管理器:
with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
plt.plot(x, a)
“rc”字典优先于从“fname”加载的设置。传递字典也是有效的。例如,常见用法是:
with mpl.rc_context(rc={'interactive': False}):
fig, ax = plt.subplots()
ax.plot(range(3), range(3))
fig.savefig('A.png', format='png')
plt.close(fig)
matplotlib.
rc
(group, **kwargs)[源代码]¶设置当前的rc参数。 组 是RC的分组,例如 lines.linewidth
该组是 lines
,为了 axes.facecolor
,该组是 axes
等等。组也可以是组名的列表或元组,例如( XICK , 伊蒂克 ) 关键字参数 是字典属性名/值对,例如:
rc('lines', linewidth=2, color='r')
设置当前rc参数并等效于:
rcParams['lines.linewidth'] = 2
rcParams['lines.color'] = 'r'
以下别名可用于保存交互式用户的键入:
别名 | 财产 |
---|---|
“LW” | “线宽” |
“LS” | “直线式” |
“C” | “颜色” |
“FC” | “脸色” |
“EC” | “EdgCeor” |
“喵” | '标记边缘宽度' |
“AA” | “反锯齿” |
因此,您可以将上面的rc命令缩写为:
rc('lines', lw=2, c='r')
注意,您可以使用python的kwargs字典工具来存储默认参数的字典。例如,您可以自定义字体rc,如下所示:
font = {'family' : 'monospace',
'weight' : 'bold',
'size' : 'larger'}
rc('font', **font) # pass in the font dict as kwargs
这使您能够轻松地在多个配置之间切换。使用 matplotlib.style.use('default')
或 rcdefaults()
在更改后恢复默认的rc参数。
matplotlib.
rc_file
(fname)[源代码]¶从文件更新rc参数。
样式黑名单RC参数(定义于 matplotlib.style.core.STYLE_BLACKLIST
)未更新。
matplotlib.
rcdefaults
()[源代码]¶从matplotlib的内部默认样式恢复rc参数。
样式黑名单RC参数(定义于 matplotlib.style.core.STYLE_BLACKLIST
)未更新。
参见
rc_file_defaults
matplotlib.style.use
style.use('default')
恢复默认样式。matplotlib.
rc_file_defaults
()[源代码]¶从matplotlib加载的原始rc文件恢复rc参数。
样式黑名单RC参数(定义于 matplotlib.style.core.STYLE_BLACKLIST
)未更新。
matplotlib.
RcParams
(*args, **kwargs)[源代码]¶字典对象,包括验证
验证函数在中定义并与rc参数关联。 matplotlib.rcsetup
find_all
(pattern)[源代码]¶返回此rcparms字典的子集,其键匹配,使用 re.search()
给定的 pattern
.
注解
对返回字典的更改是 not 传播到父RCPARMS字典。
msg_backend_obsolete
¶3.0 版后已移除: msg_backend_obsolete函数在matplotlib 3.0中已弃用,将在3.2中删除。
msg_depr
¶3.0 版后已移除: Matplotlib 3.0中的msg_depp函数已被弃用,将在3.2中删除。
msg_depr_ignore
¶3.0 版后已移除: matplotlib 3.0中的msg_depp_ignore函数已弃用,将在3.2中删除。
msg_depr_set
¶3.0 版后已移除: matplotlib 3.0中的msg_depp_set函数已弃用,将在3.2中删除。
msg_obsolete
¶3.0 版后已移除: msg_obsolete函数在matplotlib 3.0中已弃用,将在3.2中删除。
validate
= {'_internal.classic_mode': <function validate_bool>, 'agg.path.chunksize': <function validate_int>, 'animation.avconv_args': <function _listify_validator.<locals>.f>, 'animation.avconv_path': <function validate_animation_writer_path>, 'animation.bitrate': <function validate_int>, 'animation.codec': <function validate_string>, 'animation.convert_args': <function _listify_validator.<locals>.f>, 'animation.convert_path': <function validate_animation_writer_path>, 'animation.embed_limit': <function validate_float>, 'animation.ffmpeg_args': <function _listify_validator.<locals>.f>, 'animation.ffmpeg_path': <function validate_animation_writer_path>, 'animation.frame_format': <matplotlib.rcsetup.ValidateInStrings object>, 'animation.html': <matplotlib.rcsetup.ValidateInStrings object>, 'animation.html_args': <function _listify_validator.<locals>.f>, 'animation.writer': <matplotlib.rcsetup.ValidateInStrings object>, 'axes.autolimit_mode': <matplotlib.rcsetup.ValidateInStrings object>, 'axes.axisbelow': <function validate_axisbelow>, 'axes.edgecolor': <function validate_color>, 'axes.facecolor': <function validate_color>, 'axes.formatter.limits': <matplotlib.rcsetup.validate_nseq_int object>, 'axes.formatter.min_exponent': <function validate_int>, 'axes.formatter.offset_threshold': <function validate_int>, 'axes.formatter.use_locale': <function validate_bool>, 'axes.formatter.use_mathtext': <function validate_bool>, 'axes.formatter.useoffset': <function validate_bool>, 'axes.grid': <function validate_bool>, 'axes.grid.axis': <matplotlib.rcsetup.ValidateInStrings object>, 'axes.grid.which': <matplotlib.rcsetup.ValidateInStrings object>, 'axes.labelcolor': <function validate_color>, 'axes.labelpad': <function validate_float>, 'axes.labelsize': <function validate_fontsize>, 'axes.labelweight': <function validate_string>, 'axes.linewidth': <function validate_float>, 'axes.prop_cycle': <function validate_cycler>, 'axes.spines.bottom': <function validate_bool>, 'axes.spines.left': <function validate_bool>, 'axes.spines.right': <function validate_bool>, 'axes.spines.top': <function validate_bool>, 'axes.titlepad': <function validate_float>, 'axes.titlesize': <function validate_fontsize>, 'axes.titleweight': <function validate_string>, 'axes.unicode_minus': <function validate_bool>, 'axes.xmargin': <matplotlib.rcsetup.ValidateInterval object>, 'axes.ymargin': <matplotlib.rcsetup.ValidateInterval object>, 'axes3d.grid': <function validate_bool>, 'backend': <function validate_backend>, 'backend.qt4': <function validate_qt4>, 'backend.qt5': <function validate_qt5>, 'backend_fallback': <function validate_bool>, 'boxplot.bootstrap': <function validate_int_or_None>, 'boxplot.boxprops.color': <function validate_color>, 'boxplot.boxprops.linestyle': <function _validate_linestyle>, 'boxplot.boxprops.linewidth': <function validate_float>, 'boxplot.capprops.color': <function validate_color>, 'boxplot.capprops.linestyle': <function _validate_linestyle>, 'boxplot.capprops.linewidth': <function validate_float>, 'boxplot.flierprops.color': <function validate_color>, 'boxplot.flierprops.linestyle': <function _validate_linestyle>, 'boxplot.flierprops.linewidth': <function validate_float>, 'boxplot.flierprops.marker': <function validate_string>, 'boxplot.flierprops.markeredgecolor': <function validate_color>, 'boxplot.flierprops.markerfacecolor': <function validate_color_or_auto>, 'boxplot.flierprops.markersize': <function validate_float>, 'boxplot.meanline': <function validate_bool>, 'boxplot.meanprops.color': <function validate_color>, 'boxplot.meanprops.linestyle': <function _validate_linestyle>, 'boxplot.meanprops.linewidth': <function validate_float>, 'boxplot.meanprops.marker': <function validate_string>, 'boxplot.meanprops.markeredgecolor': <function validate_color>, 'boxplot.meanprops.markerfacecolor': <function validate_color>, 'boxplot.meanprops.markersize': <function validate_float>, 'boxplot.medianprops.color': <function validate_color>, 'boxplot.medianprops.linestyle': <function _validate_linestyle>, 'boxplot.medianprops.linewidth': <function validate_float>, 'boxplot.notch': <function validate_bool>, 'boxplot.patchartist': <function validate_bool>, 'boxplot.showbox': <function validate_bool>, 'boxplot.showcaps': <function validate_bool>, 'boxplot.showfliers': <function validate_bool>, 'boxplot.showmeans': <function validate_bool>, 'boxplot.vertical': <function validate_bool>, 'boxplot.whiskerprops.color': <function validate_color>, 'boxplot.whiskerprops.linestyle': <function _validate_linestyle>, 'boxplot.whiskerprops.linewidth': <function validate_float>, 'boxplot.whiskers': <function validate_whiskers>, 'contour.corner_mask': <function validate_bool>, 'contour.negative_linestyle': <function _validate_linestyle>, 'datapath': <function validate_path_exists>, 'date.autoformatter.day': <function validate_string>, 'date.autoformatter.hour': <function validate_string>, 'date.autoformatter.microsecond': <function validate_string>, 'date.autoformatter.minute': <function validate_string>, 'date.autoformatter.month': <function validate_string>, 'date.autoformatter.second': <function validate_string>, 'date.autoformatter.year': <function validate_string>, 'docstring.hardcopy': <function validate_bool>, 'errorbar.capsize': <function validate_float>, 'examples.directory': <function validate_string>, 'figure.autolayout': <function validate_bool>, 'figure.constrained_layout.h_pad': <function validate_float>, 'figure.constrained_layout.hspace': <matplotlib.rcsetup.ValidateInterval object>, 'figure.constrained_layout.use': <function validate_bool>, 'figure.constrained_layout.w_pad': <function validate_float>, 'figure.constrained_layout.wspace': <matplotlib.rcsetup.ValidateInterval object>, 'figure.dpi': <function validate_float>, 'figure.edgecolor': <function validate_color>, 'figure.facecolor': <function validate_color>, 'figure.figsize': <matplotlib.rcsetup.validate_nseq_float object>, 'figure.frameon': <function validate_bool>, 'figure.max_open_warning': <function validate_int>, 'figure.subplot.bottom': <matplotlib.rcsetup.ValidateInterval object>, 'figure.subplot.hspace': <matplotlib.rcsetup.ValidateInterval object>, 'figure.subplot.left': <matplotlib.rcsetup.ValidateInterval object>, 'figure.subplot.right': <matplotlib.rcsetup.ValidateInterval object>, 'figure.subplot.top': <matplotlib.rcsetup.ValidateInterval object>, 'figure.subplot.wspace': <matplotlib.rcsetup.ValidateInterval object>, 'figure.titlesize': <function validate_fontsize>, 'figure.titleweight': <function validate_string>, 'font.cursive': <function _listify_validator.<locals>.f>, 'font.family': <function _listify_validator.<locals>.f>, 'font.fantasy': <function _listify_validator.<locals>.f>, 'font.monospace': <function _listify_validator.<locals>.f>, 'font.sans-serif': <function _listify_validator.<locals>.f>, 'font.serif': <function _listify_validator.<locals>.f>, 'font.size': <function validate_float>, 'font.stretch': <function validate_string>, 'font.style': <function validate_string>, 'font.variant': <function validate_string>, 'font.weight': <function validate_string>, 'grid.alpha': <function validate_float>, 'grid.color': <function validate_color>, 'grid.linestyle': <function _validate_linestyle>, 'grid.linewidth': <function validate_float>, 'hatch.color': <function validate_color>, 'hatch.linewidth': <function validate_float>, 'hist.bins': <function validate_hist_bins>, 'image.aspect': <function validate_aspect>, 'image.cmap': <function validate_string>, 'image.composite_image': <function validate_bool>, 'image.interpolation': <function validate_string>, 'image.lut': <function validate_int>, 'image.origin': <function validate_string>, 'image.resample': <function validate_bool>, 'interactive': <function validate_bool>, 'keymap.all_axes': <function _listify_validator.<locals>.f>, 'keymap.back': <function _listify_validator.<locals>.f>, 'keymap.copy': <function _listify_validator.<locals>.f>, 'keymap.forward': <function _listify_validator.<locals>.f>, 'keymap.fullscreen': <function _listify_validator.<locals>.f>, 'keymap.grid': <function _listify_validator.<locals>.f>, 'keymap.grid_minor': <function _listify_validator.<locals>.f>, 'keymap.help': <function _listify_validator.<locals>.f>, 'keymap.home': <function _listify_validator.<locals>.f>, 'keymap.pan': <function _listify_validator.<locals>.f>, 'keymap.quit': <function _listify_validator.<locals>.f>, 'keymap.quit_all': <function _listify_validator.<locals>.f>, 'keymap.save': <function _listify_validator.<locals>.f>, 'keymap.xscale': <function _listify_validator.<locals>.f>, 'keymap.yscale': <function _listify_validator.<locals>.f>, 'keymap.zoom': <function _listify_validator.<locals>.f>, 'legend.borderaxespad': <function validate_float>, 'legend.borderpad': <function validate_float>, 'legend.columnspacing': <function validate_float>, 'legend.edgecolor': <function validate_color_or_inherit>, 'legend.facecolor': <function validate_color_or_inherit>, 'legend.fancybox': <function validate_bool>, 'legend.fontsize': <function validate_fontsize>, 'legend.framealpha': <function validate_float_or_None>, 'legend.frameon': <function validate_bool>, 'legend.handleheight': <function validate_float>, 'legend.handlelength': <function validate_float>, 'legend.handletextpad': <function validate_float>, 'legend.labelspacing': <function validate_float>, 'legend.loc': <matplotlib.rcsetup.ValidateInStrings object>, 'legend.markerscale': <function validate_float>, 'legend.numpoints': <function validate_int>, 'legend.scatterpoints': <function validate_int>, 'legend.shadow': <function validate_bool>, 'legend.title_fontsize': <function validate_fontsize_None>, 'lines.antialiased': <function validate_bool>, 'lines.color': <function validate_color>, 'lines.dash_capstyle': <matplotlib.rcsetup.ValidateInStrings object>, 'lines.dash_joinstyle': <matplotlib.rcsetup.ValidateInStrings object>, 'lines.dashdot_pattern': <matplotlib.rcsetup.validate_nseq_float object>, 'lines.dashed_pattern': <matplotlib.rcsetup.validate_nseq_float object>, 'lines.dotted_pattern': <matplotlib.rcsetup.validate_nseq_float object>, 'lines.linestyle': <function _validate_linestyle>, 'lines.linewidth': <function validate_float>, 'lines.marker': <function validate_string>, 'lines.markeredgecolor': <function validate_color_or_auto>, 'lines.markeredgewidth': <function validate_float>, 'lines.markerfacecolor': <function validate_color_or_auto>, 'lines.markersize': <function validate_float>, 'lines.scale_dashes': <function validate_bool>, 'lines.solid_capstyle': <matplotlib.rcsetup.ValidateInStrings object>, 'lines.solid_joinstyle': <matplotlib.rcsetup.ValidateInStrings object>, 'markers.fillstyle': <matplotlib.rcsetup.ValidateInStrings object>, 'mathtext.bf': <function validate_font_properties>, 'mathtext.cal': <function validate_font_properties>, 'mathtext.default': <matplotlib.rcsetup.ValidateInStrings object>, 'mathtext.fallback_to_cm': <function validate_bool>, 'mathtext.fontset': <matplotlib.rcsetup.ValidateInStrings object>, 'mathtext.it': <function validate_font_properties>, 'mathtext.rm': <function validate_font_properties>, 'mathtext.sf': <function validate_font_properties>, 'mathtext.tt': <function validate_font_properties>, 'patch.antialiased': <function validate_bool>, 'patch.edgecolor': <function validate_color>, 'patch.facecolor': <function validate_color>, 'patch.force_edgecolor': <function validate_bool>, 'patch.linewidth': <function validate_float>, 'path.effects': <function validate_any>, 'path.simplify': <function validate_bool>, 'path.simplify_threshold': <matplotlib.rcsetup.ValidateInterval object>, 'path.sketch': <function validate_sketch>, 'path.snap': <function validate_bool>, 'pdf.compression': <function validate_int>, 'pdf.fonttype': <function validate_fonttype>, 'pdf.inheritcolor': <function validate_bool>, 'pdf.use14corefonts': <function validate_bool>, 'pgf.preamble': <function _listify_validator.<locals>.f>, 'pgf.rcfonts': <function validate_bool>, 'pgf.texsystem': <matplotlib.rcsetup.ValidateInStrings object>, 'polaraxes.grid': <function validate_bool>, 'ps.distiller.res': <function validate_int>, 'ps.fonttype': <function validate_fonttype>, 'ps.papersize': <matplotlib.rcsetup.ValidateInStrings object>, 'ps.useafm': <function validate_bool>, 'ps.usedistiller': <function validate_ps_distiller>, 'savefig.bbox': <function validate_bbox>, 'savefig.directory': <function validate_string>, 'savefig.dpi': <function validate_dpi>, 'savefig.edgecolor': <function validate_color>, 'savefig.facecolor': <function validate_color>, 'savefig.format': <function update_savefig_format>, 'savefig.frameon': <function validate_bool>, 'savefig.jpeg_quality': <function validate_int>, 'savefig.orientation': <matplotlib.rcsetup.ValidateInStrings object>, 'savefig.pad_inches': <function validate_float>, 'savefig.transparent': <function validate_bool>, 'scatter.marker': <function validate_string>, 'svg.fonttype': <function validate_svg_fonttype>, 'svg.hashsalt': <function validate_string_or_None>, 'svg.image_inline': <function validate_bool>, 'text.antialiased': <function validate_bool>, 'text.color': <function validate_color>, 'text.hinting': <function validate_hinting>, 'text.hinting_factor': <function validate_int>, 'text.latex.preamble': <function _listify_validator.<locals>.f>, 'text.latex.preview': <function validate_bool>, 'text.latex.unicode': <function validate_bool>, 'text.usetex': <function validate_bool>, 'timezone': <function validate_string>, 'tk.window_focus': <function validate_bool>, 'toolbar': <function validate_toolbar>, 'verbose.fileo': <function validate_string>, 'verbose.level': <matplotlib.rcsetup.ValidateInStrings object>, 'webagg.address': <function validate_webagg_address>, 'webagg.open_in_browser': <function validate_bool>, 'webagg.port': <function validate_int>, 'webagg.port_retries': <function validate_int>, 'xtick.alignment': <matplotlib.rcsetup.ValidateInStrings object>, 'xtick.bottom': <function validate_bool>, 'xtick.color': <function validate_color>, 'xtick.direction': <function validate_string>, 'xtick.labelbottom': <function validate_bool>, 'xtick.labelsize': <function validate_fontsize>, 'xtick.labeltop': <function validate_bool>, 'xtick.major.bottom': <function validate_bool>, 'xtick.major.pad': <function validate_float>, 'xtick.major.size': <function validate_float>, 'xtick.major.top': <function validate_bool>, 'xtick.major.width': <function validate_float>, 'xtick.minor.bottom': <function validate_bool>, 'xtick.minor.pad': <function validate_float>, 'xtick.minor.size': <function validate_float>, 'xtick.minor.top': <function validate_bool>, 'xtick.minor.visible': <function validate_bool>, 'xtick.minor.width': <function validate_float>, 'xtick.top': <function validate_bool>, 'ytick.alignment': <matplotlib.rcsetup.ValidateInStrings object>, 'ytick.color': <function validate_color>, 'ytick.direction': <function validate_string>, 'ytick.labelleft': <function validate_bool>, 'ytick.labelright': <function validate_bool>, 'ytick.labelsize': <function validate_fontsize>, 'ytick.left': <function validate_bool>, 'ytick.major.left': <function validate_bool>, 'ytick.major.pad': <function validate_float>, 'ytick.major.right': <function validate_bool>, 'ytick.major.size': <function validate_float>, 'ytick.major.width': <function validate_float>, 'ytick.minor.left': <function validate_bool>, 'ytick.minor.pad': <function validate_float>, 'ytick.minor.right': <function validate_bool>, 'ytick.minor.size': <function validate_float>, 'ytick.minor.visible': <function validate_bool>, 'ytick.minor.width': <function validate_float>, 'ytick.right': <function validate_bool>}¶matplotlib.
rc_params
(fail_on_error=False)[源代码]¶返回A matplotlib.RcParams
来自默认matplotlib rc文件的实例。
matplotlib.
rc_params_from_file
(fname, fail_on_error=False, use_default_template=True)[源代码]¶返回 matplotlib.RcParams
从给定文件的内容。
参数: |
|
---|
matplotlib.
matplotlib_fname
()[源代码]¶获取配置文件的位置。
文件位置按以下顺序确定
$PWD/matplotlibrc
$MATPLOTLIBRC
如果是文件(或命名管道,可以通过流程替换等方式创建)
$MATPLOTLIBRC/matplotlibrc
$MPLCONFIGDIR/matplotlibrc
在Linux上,
$XDG_CONFIG_HOME/matplotlib/matplotlibrc
(如果定义了$xdg_config_home)- 或
$HOME/.config/matplotlib/matplotlibrc
(如果未定义$xdg_config_home)
在其他平台上,
$HOME/.matplotlib/matplotlibrc
如果$HOME
定义。
最后,它看起来 $MATPLOTLIBDATA/matplotlibrc
对于系统定义的副本。