注意
转到页面底部 下载完整示例代码。
Matplotlib 配置 - rcParams#
Matplotlib 的配置参数 (rcParams) 控制着绘图的行为和外观。这些参数存储在一个名为 matplotlib.rcParams 的字典类变量中(也可以通过 plt.rcParams 访问)。
以下是所有可用 rcParams 及其默认值的综合参考。
后端 (Backends)#
- webagg.port:
8988 WebAgg 后端中 Web 服务器使用的端口。
- webagg.address:
'127.0.0.1' WebAgg Web 服务器应监听的地址。
- webagg.port_retries:
50 如果 webagg.port 不可用,将尝试随机选择其他端口,直到找到可用端口为止。
- webagg.open_in_browser:
True 如果为 True,则在展示绘图时自动打开浏览器
- backend_fallback:
True 如果您在 GUI 中运行 pyplot 且后端选择冲突,当 backend_fallback 为 True 时,我们将自动尝试为您寻找一个兼容的后端
- interactive:
False 无描述
- figure.hooks:
[] 格式为 dotted.module.name:dotted.callable.name 的列表
- toolbar:
'toolbar2' {None, toolbar2, toolmanager}
- timezone:
'UTC' pytz 时区字符串,例如 US/Central 或 Europe/Paris
线条 (Lines)#
线对象的默认属性,例如 plot() 返回的对象。
- lines.linewidth:
1.5 线宽(以点为单位)
- lines.linestyle:
'-' 实线
- lines.color:
'C0' 对 plot() 无影响;请参阅 axes.prop_cycle
- lines.marker:
'None' 默认标记
- lines.markerfacecolor:
'auto' 默认标记填充颜色
- lines.markeredgecolor:
'auto' 默认标记边缘颜色
- lines.markeredgewidth:
1.0 标记符号周围的线宽
- lines.markersize:
6.0 标记大小(以点为单位)
- lines.dash_joinstyle:
'round' {miter, round, bevel}
- lines.dash_capstyle:
'butt' {butt, round, projecting}
- lines.solid_joinstyle:
'round' {miter, round, bevel}
- lines.solid_capstyle:
'projecting' {butt, round, projecting}
- lines.antialiased:
True 渲染线条时使用抗锯齿(消除锯齿)
- lines.dashed_pattern:
[3.7, 1.6] linestyle 为 'dashed' 时的虚线模式
- lines.dashdot_pattern:
[6.4, 1.6, 1.0, 1.6] linestyle 为 'dashdot' 时的虚点线模式
- lines.dotted_pattern:
[1.0, 1.65] linestyle 为 'dotted' 时的点线模式
- lines.scale_dashes:
True 无描述
- markers.fillstyle:
'full' {full, left, right, bottom, top, none}
- pcolor.shading:
'auto' 无描述
- pcolormesh.snap:
True 是否将网格对齐到像素边界。此设置旨在保持旧测试图像外观不变。设置为 False 可获得之前的行为。
补丁 (Patches)#
- patch.linewidth:
1.0 边缘宽度(以点为单位)
- patch.facecolor:
'C0' 无描述
- patch.edgecolor:
'black' 默认情况下,补丁 (Patches) 和集合 (Collections) 不绘制边缘。此值仅在 facecolor 为 "none" 时使用(没有填充色和边缘色的 Artist 将不可见),或者当 patch.force_edgecolor 为 True 时使用。
- patch.force_edgecolor:
False 默认情况下,补丁和集合不绘制边缘。设置为 True 以使用 patch.edgecolor 作为默认边缘颜色。这主要与样式相关。
- patch.antialiased:
True 渲染补丁时使用抗锯齿
填充图案 (Hatches)#
- hatch.color:
'edge' 无描述
- hatch.linewidth:
1.0 无描述
箱线图 (Boxplot)#
- boxplot.notch:
False 无描述
- boxplot.vertical:
True 无描述
- boxplot.whiskers:
1.5 无描述
- boxplot.bootstrap:
None 无描述
- boxplot.patchartist:
False 无描述
- boxplot.showmeans:
False 无描述
- boxplot.showcaps:
True 无描述
- boxplot.showbox:
True 无描述
- boxplot.showfliers:
True 无描述
- boxplot.meanline:
False 无描述
- boxplot.flierprops.color:
'black' 无描述
- boxplot.flierprops.marker:
'o' 无描述
- boxplot.flierprops.markerfacecolor:
'none' 无描述
- boxplot.flierprops.markeredgecolor:
'black' 无描述
- boxplot.flierprops.markeredgewidth:
1.0 无描述
- boxplot.flierprops.markersize:
6.0 无描述
- boxplot.flierprops.linestyle:
'none' 无描述
- boxplot.flierprops.linewidth:
1.0 无描述
- boxplot.boxprops.color:
'black' 无描述
- boxplot.boxprops.linewidth:
1.0 无描述
- boxplot.boxprops.linestyle:
'-' 无描述
- boxplot.whiskerprops.color:
'black' 无描述
- boxplot.whiskerprops.linewidth:
1.0 无描述
- boxplot.whiskerprops.linestyle:
'-' 无描述
- boxplot.capprops.color:
'black' 无描述
- boxplot.capprops.linewidth:
1.0 无描述
- boxplot.capprops.linestyle:
'-' 无描述
- boxplot.medianprops.color:
'C1' 无描述
- boxplot.medianprops.linewidth:
1.0 无描述
- boxplot.medianprops.linestyle:
'-' 无描述
- boxplot.meanprops.color:
'C2' 无描述
- boxplot.meanprops.marker:
'^' 无描述
- boxplot.meanprops.markerfacecolor:
'C2' 无描述
- boxplot.meanprops.markeredgecolor:
'C2' 无描述
- boxplot.meanprops.markersize:
6.0 无描述
- boxplot.meanprops.linestyle:
'--' 无描述
- boxplot.meanprops.linewidth:
1.0 无描述
字体 (Font)#
Text 使用的字体属性。有关字体属性的更多信息,请参阅 https://matplotlib.org.cn/stable/api/font_manager_api.html。用于字体匹配的 6 个字体属性及其默认值如下所示。
- font.family:
['sans-serif'] 无描述
- font.style:
'normal' 无描述
- font.variant:
'normal' 无描述
- font.weight:
'normal' 无描述
- font.stretch:
'normal' 无描述
- font.size:
10.0 无描述
- font.serif:
['DejaVu Serif', 'Bitstream Vera Serif', 'Computer Modern Roman', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif'] 无描述
- font.sans-serif:
['DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif'] 无描述
- font.cursive:
['Apple Chancery', 'Textile', 'Zapf Chancery', 'Sand', 'Script MT', 'Felipa', 'Comic Neue', 'Comic Sans MS', 'cursive'] 无描述
- font.fantasy:
['Chicago', 'Charcoal', 'Impact', 'Western', 'xkcd script', 'fantasy'] 无描述
- font.monospace:
['DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Computer Modern Typewriter', 'Andale Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', 'monospace'] 无描述
- font.enable_last_resort:
True 如果为 True,则 Unicode 联盟的“最后手段 (Last Resort)”字体将被追加到所有字体选择中。这确保始终可以显示字形。
文本属性 (Text properties)#
- text.color:
'black' 无描述
- text.language:
None 文本语言,格式需被 libraqm 接受,即 BCP47 语言代码。如果为 None,则不隐含特定语言,并将使用默认字体设置。
- text.hinting:
'default' FreeType 微调 (hinting) 标志("foo" 对应 FT_LOAD_FOO);可以是以下之一(括号内为 Matplotlib 特有的专有同义词,但不建议使用): - default: 如果可能,使用字体的原生微调器,否则使用 FreeType 的自动微调器。("either" 是同义词)- no_autohint: 如果可能,使用字体的原生微调器,否则不进行微调。("native" 是同义词)- force_autohint: 使用 FreeType 的自动微调器。("auto" 是同义词)- no_hinting: 禁用微调。("none" 是同义词)
- text.hinting_factor:
None [已弃用] 此设置无效。
- text.kerning_factor:
None [已弃用] 指定字距调整 (kerning) 值的缩放因子。仅用于保持旧测试图像外观不变。设置为 6 可获得以前的行为。除 0 或 6 之外的值没有明确含义。
- text.antialiased:
True 如果为 True(默认),文本将进行抗锯齿处理。仅影响栅格化输出。
- text.parse_math:
True 如果存在偶数个未转义的美元符号,则使用 mathtext。
Mathtext 和 LaTeX#
- text.usetex:
False 使用 LaTeX 处理所有文本。通过常见的 rc 参数设置支持以下字体:new century schoolbook, bookman, times, palatino, zapf chancery, charter, serif, sans-serif, helvetica, avant garde, courier, monospace, computer modern roman, computer modern sans serif, computer modern typewriter
- text.latex.engine:
'latex' 使用的 TeX 引擎/格式。支持以下值: - 'latex': 经典 TeX 引擎(当前默认值)。所有后端通过解析 DVI 输出为字形和框并逐一输出它们来渲染 TeX 的结果。 - 'latex+dvipng': 除基于 Agg 的后端依赖 dvipng 对 TeX 输出进行栅格化外,与 'latex' 相同。在 Matplotlib 3.10 之前,此值是默认值。
- text.latex.preamble:
'' 不当使用此功能会导致 LATEX 失败,因此不支持。如果此功能未达到您的预期,请不要寻求帮助。text.latex.preamble 是传递给 LaTeX 系统的一行 LaTeX 代码。它可能包含任何对 LaTeX "前言 (preamble)" 有效的代码,即在 "documentclass" 和 "begin{document}" 语句之间的代码。注意它必须放在单行上,该行可能会变得很长。在使用 usetex 时,以下包始终会被加载,请注意包冲突:color, fix-cm, geometry, graphicx, textcomp。根据您的字体设置,PostScript (PSNFSS) 字体包也可能被加载。
- mathtext.fontset:
'dejavusans' 应为 'dejavusans'(默认)、'dejavuserif'、'cm' (Computer Modern)、'stix'、'stixsans' 或 'custom'
- mathtext.bf:
'sans:bold' 无描述
- mathtext.bfit:
'sans:italic:bold' 无描述
- mathtext.cal:
'cursive' 无描述
- mathtext.it:
'sans:italic' 无描述
- mathtext.rm:
'sans' 无描述
- mathtext.sf:
'sans' 无描述
- mathtext.tt:
'monospace' 无描述
- mathtext.fallback:
'cm' 当自定义数学字体中找不到符号时,从 ['cm' (Computer Modern), 'stix', 'stixsans'] 中选择备用字体。选择 'None' 则不进行回退,并用虚拟符号替换丢失的字符。
- mathtext.default:
'normal' 用于数学的默认字体。可以是任何 LaTeX 字体名称,包括特殊名称 "regular"(与普通文本中使用的字体相同)。
坐标轴 (Axes)#
- axes.facecolor:
'white' 坐标轴背景色
- axes.edgecolor:
'black' 坐标轴边缘颜色
- axes.linewidth:
0.8 边缘线宽
- axes.grid:
False 是否显示网格
- axes.grid.axis:
'both' 网格应应用到的坐标轴
- axes.grid.which:
'major' 网格线位于 {major, minor, both} 刻度处
- axes.titlelocation:
'center' 标题对齐方式:{left, right, center}
- axes.titlesize:
'large' 坐标轴标题字体大小
- axes.titleweight:
'normal' 标题字体粗细
- axes.titlecolor:
'auto' 坐标轴标题颜色,auto 表示回退到 text.color 作为默认值
- axes.titley:
None 放置标题(相对于坐标轴的单位)。None 意味着自动
- axes.titlepad:
6.0 坐标轴与标题之间的填充(以点为单位)
- axes.labelsize:
'medium' x 轴和 y 轴标签的字体大小
- axes.labelpad:
4.0 标签与坐标轴之间的间距
- axes.labelweight:
'normal' x 轴和 y 轴标签的粗细
- axes.labelcolor:
'black' 无描述
- axes.axisbelow:
'line' 绘制坐标轴网格线和刻度: - 在补丁之下 (True) - 在补丁之上但在线条之下 ('line') - 在所有内容之上 (False)
- axes.formatter.limits:
[-5, 6] 如果坐标轴范围的 log10 值小于第一个数或大于第二个数,则使用科学记数法
- axes.formatter.use_locale:
False 当为 True 时,根据用户区域设置格式化刻度标签。例如,在 fr_FR 区域设置中使用 ',' 作为小数点分隔符。
- axes.formatter.use_mathtext:
False 当为 True 时,使用 mathtext 表示科学记数法。
- axes.formatter.min_exponent:
0 科学记数法中格式化的最小指数
- axes.formatter.useoffset:
True 如果为 True,当数据范围与数据的最小绝对值相比很小时,刻度标签格式化程序将默认相对于偏移量进行标记。
- axes.formatter.offset_threshold:
4 当 useoffset 为 True 时,如果偏移量能从刻度标签中去除至少此位数的有效数字,则将使用偏移量。
- axes.spines.left:
True 显示坐标轴脊 (spines)
- axes.spines.bottom:
True 无描述
- axes.spines.top:
True 无描述
- axes.spines.right:
True 无描述
- axes.unicode_minus:
True 使用 Unicode 减号而非连字符。请参阅 https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
- axes.prop_cycle:
cycler('color', [(0.12156862745098039, 0.4666666666666667, 0.7058823529411765), (1.0, 0.4980392156862745, 0.054901960784313725), (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), (0.8392156862745098, 0.15294117647058825, 0.1568627450980392), (0.5803921568627451, 0.403921568627451, 0.7411764705882353), (0.5490196078431373, 0.33725490196078434, 0.29411764705882354), (0.8901960784313725, 0.4666666666666667, 0.7607843137254902), (0.4980392156862745, 0.4980392156862745, 0.4980392156862745), (0.7372549019607844, 0.7411764705882353, 0.13333333333333333), (0.09019607843137255, 0.7450980392156863, 0.8117647058823529)]) 无描述
- axes.xmargin:
0.05 x 轴页边距。请参阅
margins
- axes.ymargin:
0.05 y 轴页边距。请参阅
margins
- axes.zmargin:
0.05 z 轴页边距。请参阅
margins
- axes.autolimit_mode:
'data' 如果为 "data",则直接按原样使用 axes.xmargin 和 axes.ymargin。如果为 "round_numbers",在应用页边距后,坐标轴限制会进一步扩展到最近的“整数”。
极坐标轴 (Polar Axes)#
- polaraxes.grid:
True 在极坐标轴上显示网格
3D 坐标轴 (3D Axes)#
- axes3d.grid:
True 在 3D 坐标轴上显示网格
- axes3d.automargin:
False 手动设置 3D 坐标轴限制时自动添加页边距
- axes3d.xaxis.panecolor:
(0.95, 0.95, 0.95, 0.5) 3D 坐标轴上的背景面板
- axes3d.yaxis.panecolor:
(0.9, 0.9, 0.9, 0.5) 3D 坐标轴上的背景面板
- axes3d.zaxis.panecolor:
(0.925, 0.925, 0.925, 0.5) 3D 坐标轴上的背景面板
- axes3d.depthshade:
True 3D 散点图的深度阴影
- axes3d.depthshade_minalpha:
0.3 深度阴影的最小 alpha 值
- axes3d.mouserotationstyle:
'arcball' {azel, trackball, sphere, arcball} 另请参阅 https://matplotlib.org.cn/stable/api/toolkits/mplot3d/view_angles.html#rotation-with-mouse
- axes3d.trackballsize:
0.667 轨迹球直径,以坐标轴边界框 (Axes bbox) 为单位
- axes3d.trackballborder:
0.2 轨迹球边框宽度,以坐标轴边界框为单位(仅适用于 'sphere' 和 'arcball' 样式)
坐标轴#
- axes3d.snap_rotation:
5.0 按住 Control 键进行 3D 旋转时的吸附角度(以度为单位)。
- xaxis.labellocation:
'center' xaxis 标签对齐方式:{left, right, center}
- yaxis.labellocation:
'center' yaxis 标签对齐方式:{bottom, top, center}
日期 (Dates)#
日期刻度标签的默认属性。当检测到相应的时间单位时,这些属性由 AutoDateFormatter 使用。有关更多信息,请参阅 https://matplotlib.org.cn/stable/api/dates_api.html#date-formatters。
- date.autoformatter.year:
'%Y' 无描述
- date.autoformatter.month:
'%Y-%m' 无描述
- date.autoformatter.day:
'%Y-%m-%d' 无描述
- date.autoformatter.hour:
'%m-%d %H' 无描述
- date.autoformatter.minute:
'%d %H:%M' 无描述
- date.autoformatter.second:
'%H:%M:%S' 无描述
- date.autoformatter.microsecond:
'%M:%S.%f' 无描述
- date.epoch:
'1970-01-01T00:00:00' Matplotlib 内部日期表示的参考日期。请参阅 https://matplotlib.org.cn/stable/gallery/ticks/date_precision_and_epochs.html
- date.converter:
'auto' 'auto', 'concise'
- date.interval_multiples:
True 对于自动转换器,是否使用 interval_multiples
刻度#
- xtick.top:
False 在顶部绘制刻度
- xtick.bottom:
True 在底部绘制刻度
- xtick.labeltop:
False 在顶部绘制标签
- xtick.labelbottom:
True 在底部绘制标签
- xtick.major.size:
3.5 主刻度大小(以点为单位)
- xtick.minor.size:
2.0 次刻度大小(以点为单位)
- xtick.major.width:
0.8 主刻度宽度(以点为单位)
- xtick.minor.width:
0.6 次刻度宽度(以点为单位)
- xtick.major.pad:
3.5 到主刻度标签的距离(以点为单位)
- xtick.minor.pad:
3.4 到次刻度标签的距离(以点为单位)
- xtick.color:
'black' 刻度颜色
- xtick.labelcolor:
'inherit' 刻度标签颜色,或从 xtick.color 继承
- xtick.labelsize:
'medium' 刻度标签字体大小
- xtick.direction:
'out' 方向:{in, out, inout}
- xtick.minor.visible:
False x 轴上次刻度的可见性
- xtick.major.top:
True 绘制 x 轴顶部主刻度
- xtick.major.bottom:
True 绘制 x 轴底部主刻度
- xtick.minor.top:
True 绘制 x 轴顶部次刻度
- xtick.minor.bottom:
True 绘制 x 轴底部次刻度
- xtick.minor.ndivs:
'auto' x 轴上主刻度之间的次刻度数量
- xtick.alignment:
'center' x 刻度对齐方式
- ytick.left:
True 在左侧绘制刻度
- ytick.right:
False 在右侧绘制刻度
- ytick.labelleft:
True 在左侧绘制刻度标签
- ytick.labelright:
False 在右侧绘制刻度标签
- ytick.major.size:
3.5 主刻度大小(以点为单位)
- ytick.minor.size:
2.0 次刻度大小(以点为单位)
- ytick.major.width:
0.8 主刻度宽度(以点为单位)
- ytick.minor.width:
0.6 次刻度宽度(以点为单位)
- ytick.major.pad:
3.5 到主刻度标签的距离(以点为单位)
- ytick.minor.pad:
3.4 到次刻度标签的距离(以点为单位)
- ytick.color:
'black' 刻度颜色
- ytick.labelcolor:
'inherit' 刻度标签颜色,或从 ytick.color 继承
- ytick.labelsize:
'medium' 刻度标签字体大小
- ytick.direction:
'out' 方向:{in, out, inout}
- ytick.minor.visible:
False y 轴上次刻度的可见性
- ytick.major.left:
True 绘制 y 轴左侧主刻度
- ytick.major.right:
True 绘制 y 轴右侧主刻度
- ytick.minor.left:
True 绘制 y 轴左侧次刻度
- ytick.minor.right:
True 绘制 y 轴右侧次刻度
- ytick.minor.ndivs:
'auto' y 轴上主刻度之间的次刻度数量
- ytick.alignment:
'center_baseline' y 刻度对齐方式
网格 (Grid)#
- grid.color:
'#b0b0b0' b0b0b0" # 网格颜色
- grid.linestyle:
'-' 实线
- grid.linewidth:
0.8 以点为单位
- grid.alpha:
1.0 透明度,在 0.0 到 1.0 之间
- grid.major.color:
None 如果为 None,则默认为 grid.color
- grid.major.linestyle:
None 如果为 None,则默认为 grid.linestyle
- grid.major.linewidth:
None 如果为 None,则默认为 grid.linewidth
- grid.major.alpha:
None 如果为 None,则默认为 grid.alpha
- grid.minor.color:
None 如果为 None,则默认为 grid.color
- grid.minor.linestyle:
None 如果为 None,则默认为 grid.linestyle
- grid.minor.linewidth:
None 如果为 None,则默认为 grid.linewidth
- grid.minor.alpha:
None 如果为 None,则默认为 grid.alpha
图例 (Legend)#
- legend.loc:
'best' 无描述
- legend.frameon:
True 如果为 True,则在背景补丁上绘制图例
- legend.framealpha:
0.8 图例补丁透明度
- legend.facecolor:
'inherit' 从 axes.facecolor 继承;或指定颜色
- legend.edgecolor:
'0.8' 背景补丁边界颜色
- legend.linewidth:
None 图例框架的线宽,None 表示从 patch.linewidth 继承
- legend.fancybox:
True 如果为 True,则使用圆角矩形作为图例背景,否则使用矩形
- legend.shadow:
False 如果为 True,则为背景添加阴影效果
- legend.numpoints:
1 图例线条中的标记点数量
- legend.scatterpoints:
1 散点图点数
- legend.markerscale:
1.0 图例标记相对于原始标记的大小
- legend.fontsize:
'medium' 无描述
- legend.labelcolor:
'None' 无描述
- legend.title_fontsize:
None None 设置为与默认 axes 相同。
- legend.borderpad:
0.4 边框空白
- legend.labelspacing:
0.5 图例条目之间的垂直空间
- legend.handlelength:
2.0 图例线条的长度
- legend.handleheight:
0.7 图例句柄的高度
- legend.handletextpad:
0.8 图例线条和图例文本之间的间距
- legend.borderaxespad:
0.5 坐标轴和图例边缘之间的边框
- legend.columnspacing:
2.0 列间距
图形 (Figure)#
- figure.titlesize:
'large' 图形标题的大小 (
Figure.suptitle())
- figure.titleweight:
'normal' 图形标题的粗细
- figure.labelsize:
'large' 图形标签的大小 (
Figure.sup[x|y]label())
- figure.labelweight:
'normal' 图形标签的粗细
- figure.figsize:
[6.4, 4.8] 图形尺寸(以英寸为单位)
- figure.dpi:
100.0 图形每英寸点数
- figure.facecolor:
'white' 图形背景颜色
- figure.edgecolor:
'white' 图形边缘颜色
- figure.frameon:
True 启用图形框架
- figure.max_open_warning:
20 通过 pyplot 界面打开的最大图形数量,超过此数量将发出警告。如果小于 1,则禁用此功能。
- figure.raise_window:
True 调用 show() 时将 GUI 窗口置于最前。如果设置为 False,我们目前不会采取任何进一步行动,窗口是否出现在最前取决于 GUI 框架和窗口管理器。
- figure.subplot.left:
0.125 图形子图的左侧
- figure.subplot.right:
0.9 图形子图的右侧
- figure.subplot.bottom:
0.11 图形子图的底部
- figure.subplot.top:
0.88 图形子图的顶部
- figure.subplot.wspace:
0.2 为子图之间留出的宽度,表示为平均坐标轴宽度的分数
- figure.subplot.hspace:
0.2 为子图之间留出的高度,表示为平均坐标轴高度的分数
- figure.autolayout:
False 当为 True 时,自动调整子图参数以使绘图适合使用
tight_layout的图形
- figure.constrained_layout.use:
False 当为 True 时,自动使绘图元素适合图形。(与上面的 "figure.autolayout" 不兼容)。
- figure.constrained_layout.h_pad:
0.04167 坐标轴周围的填充(以英寸为单位);默认为 3/72 英寸,即 3 点
- figure.constrained_layout.w_pad:
0.04167 坐标轴周围的填充(以英寸为单位);默认为 3/72 英寸,即 3 点
- figure.constrained_layout.hspace:
0.02 子图之间的间距,相对于子图大小。比 tight_layout(figure.subplot.hspace, figure.subplot.wspace)小得多,因为 constrained_layout 已经考虑了周围的文本(标题、标签、刻度标签)。
- figure.constrained_layout.wspace:
0.02 子图之间的间距,相对于子图大小。比 tight_layout(figure.subplot.hspace, figure.subplot.wspace)小得多,因为 constrained_layout 已经考虑了周围的文本(标题、标签、刻度标签)。
图像 (Images)#
- image.aspect:
'equal' {equal, auto} 或数字
- image.interpolation:
'auto' 有关选项,请参阅 help(imshow)
- image.interpolation_stage:
'auto' 有关选项,请参阅 help(imshow)
- image.cmap:
'viridis' 色图名称 (plasma, magma 等)
- image.lut:
256 色图查找表的大小
- image.origin:
'upper' {lower, upper}
- image.resample:
True 无描述
- image.composite_image:
True 当为 True 时,在将图形保存为矢量图形文件(如 PDF)之前,坐标轴上所有的图像都会组合成单个复合图像。
等高线图 (Contour plots)#
- contour.negative_linestyle:
'dashed' 字符串或开-关墨水序列
- contour.corner_mask:
True {True, False}
- contour.linewidth:
None {float, None} 等高线条宽大小。如果设置为 None,则回退到 "line.linewidth"。
- contour.algorithm:
'mpl2014' {mpl2005, mpl2014, serial, threaded}
误差条图 (Errorbar plots)#
- errorbar.capsize:
0.0 误差条末端盖的长度(以像素为单位)
- errorbar.capthick:
None 误差条末端盖的厚度(以点为单位)。
- errorbar.elinewidth:
None 误差条线的线宽(以点为单位)。
直方图 (Histogram plots)#
- hist.bins:
10 直方图箱的默认数量或 'auto'。
散点图 (Scatter plots)#
- scatter.marker:
'o' 散点图的默认标记类型。
- scatter.edgecolors:
'face' 散点图的默认边缘颜色。
AGG 渲染 (AGG rendering)#
- agg.path.chunksize:
0 0 表示禁用;10000 到 100000 范围内的值可以稍微提高速度,并在绘制非常大的数据集(尤其是如果数据非常稀疏时)时防止 Agg 渲染失败。不过它可能会导致轻微的伪影。值 20000 可能是一个不错的起点。
路径 (Paths)#
- path.simplify:
True 当为 True 时,通过移除“不可见”点来简化路径,以减少文件大小并提高渲染速度
- path.simplify_threshold:
0.111111111111 简化过程中移除顶点的相似度阈值。
- path.snap:
True 当为 True 时,满足某些条件时,直线轴对齐的路径将被对齐到最近的像素。当为 False 时,路径将永远不会被对齐。
- path.sketch:
None 可以是 None,或者是以下形式的元组:path.sketch: (scale, length, randomness)- scale 是垂直于线条的摆动幅度(以像素为单位)。- length 是沿线条的摆动长度(以像素为单位)。- randomness 是长度随机缩放的因子。
- path.effects:
[] 无描述
保存图形 (Saving figures)#
- savefig.dpi:
'figure' 图形每英寸点数或 'figure'
- savefig.facecolor:
'auto' 保存时的图形背景色
- savefig.edgecolor:
'auto' 保存时的图形边缘颜色
- savefig.format:
'png' {png, ps, pdf, svg}
- savefig.bbox:
None {tight, standard} 'tight' 与生成动画帧不兼容
- savefig.pad_inches:
0.1 当 bbox 设置为 'tight' 时使用的填充
- savefig.directory:
'~' 保存对话框中的默认目录,交互式保存后会更新,除非设置为空字符串(即当前目录);使用 '.' 可从当前目录开始,但在交互式保存后更新
- savefig.transparent:
False 图形是否默认以透明背景保存
- savefig.orientation:
'portrait' 保存图形的方向,仅用于 PostScript 输出
Mac OSX 后端参数#
- macosx.window_mode:
'system' 如何打开新图形 (system, tab, window),system 使用 MacOS 系统偏好设置
Tk 后端参数#
- tk.window_focus:
False 为 TkAgg 保持 shell 焦点
PS 后端参数#
- ps.papersize:
'letter' {figure, letter, legal, ledger, A0-A10, B0-B10}
- ps.useafm:
False 使用 AFM 字体,产生小文件
- ps.usedistiller:
None {ghostscript, xpdf, None} 实验性:可能会产生更小的文件。xpdf 旨在制作出版级质量的文件,但需要 ghostscript, xpdf 和 ps2eps
- ps.distiller.res:
6000 dpi
- ps.fonttype:
3 输出类型 3 (Type3) 或类型 42 (TrueType)
PDF 后端参数#
- pdf.compression:
6 0 到 9 之间的整数,0 禁用压缩(利于调试)
- pdf.fonttype:
3 输出类型 3 (Type3) 或类型 42 (TrueType)
- pdf.use14corefonts:
False 无描述
- pdf.inheritcolor:
False 无描述
SVG 后端参数#
- svg.image_inline:
True 将栅格图像数据直接写入 SVG 文件
- svg.fonttype:
'path' 如何处理 SVG 字体:path:将字符嵌入为路径 -- 大多数 SVG 渲染器支持;none:假设字体安装在查看 SVG 的机器上。
- svg.hashsalt:
None 如果不为 None,则使用此字符串作为哈希盐 (hash salt) 而不是 uuid4
- svg.id:
None 如果不为 None,则将此字符串用作顶级 <svg> 标签中
id属性的值
PGF 参数#
- pgf.rcfonts:
True 无描述
- pgf.preamble:
'' 有关文档,请参阅 text.latex.preamble
- pgf.texsystem:
'xelatex' 无描述
文档字符串参数 (Docstring parameters)#
- docstring.hardcopy:
False 当您想要生成硬拷贝文档字符串时设置此项
交互式快捷键 (Interactive keymaps)#
交互式导航的默认快捷键映射。请参阅 导航键盘快捷键。
- keymap.fullscreen:
['f', 'ctrl+f'] 切换
- keymap.home:
['h', 'r', 'home'] 主页或重置助记符
- keymap.back:
['left', 'c', 'backspace', 'MouseButton.BACK'] 前进/后退键
- keymap.forward:
['right', 'v', 'MouseButton.FORWARD'] 用于快速导航
- keymap.pan:
['p'] 平移助记符
- keymap.zoom:
['o'] 缩放助记符
- keymap.save:
['s', 'ctrl+s'] 保存当前图形
- keymap.help:
['f1'] 显示关于活动工具的帮助
- keymap.quit:
['ctrl+w', 'cmd+w', 'q'] 关闭当前图形
- keymap.quit_all:
[] 关闭所有图形
- keymap.grid:
['g'] 开启/关闭当前坐标轴上的主网格
- keymap.grid_minor:
['G'] 开启/关闭当前坐标轴上的次网格
- keymap.yscale:
['l'] 切换 y 轴缩放 ('log'/'linear')
- keymap.xscale:
['k', 'L'] 切换 x 轴缩放 ('log'/'linear')
- keymap.copy:
['ctrl+c', 'cmd+c'] 将图形复制到剪贴板
动画#
- animation.html:
'none' 如何在 IPython 笔记本中以 HTML 显示动画: - 'html5' 使用 HTML5 视频标签 - 'jshtml' 创建 JavaScript 动画
- animation.writer:
'ffmpeg' 使用的 MovieWriter '后端'
- animation.codec:
'h264' 用于编写电影的编解码器
- animation.bitrate:
-1 控制电影大小/质量的平衡。-1 表示让工具自动确定
- animation.frame_format:
'png' 控制临时文件使用的帧格式
- animation.ffmpeg_path:
'ffmpeg' ffmpeg 二进制文件的路径。非限定路径由 subprocess.Popen 解析。
- animation.ffmpeg_args:
[] 传递给 ffmpeg 的附加参数
- animation.convert_path:
'convert' ImageMagick 的 convert 二进制文件的路径。非限定路径由 subprocess.Popen 解析,但在 Windows 上,我们在注册表中查找 ImageMagick 的安装(因为 convert 也是系统工具的名称)。
- animation.convert_args:
['-layers', 'OptimizePlus'] 传递给 convert 的附加参数
- animation.embed_limit:
20.0 HTML(即 IPython 笔记本)中 base64 编码动画大小的限制(以 MB 为单位)
- backend:
None 无描述