matplotlib.style#

样式是预定义的一组 rcParams>,它们定义了绘图的视觉外观。

使用样式表和rcParams自定义Matplotlib 描述了样式的机制和用法。

样式表参考 概述了内置样式。

matplotlib.style.context(style, after_reset=False)[source]#

用于临时使用样式设置的上下文管理器。

参数:
stylestr, dict, Path or list

样式规范。有效选项包括:

str
字典

matplotlib.rcParams 的键/值对映射。

Path

样式文件的路径,由 rc_params_from_file 加载。

list

样式说明符(str、Path 或 dict)列表,按列表中从第一个到最后一个的顺序应用。

after_resetbool

如果为 True,则在将设置重置为默认值后应用样式;否则,在当前设置之上应用样式。

matplotlib.style.reload_library()[source]#

重新加载样式库。

matplotlib.style.use(style)[source]#

使用样式规范中的 Matplotlib 样式设置。

样式名称 'default' 保留用于恢复默认样式设置。

注意

这将使用样式中的设置更新 rcParams>。样式中未定义的 rcParams> 将保持不变。

参数:
stylestr, dict, Path or list

样式规范。有效选项包括:

str
字典

matplotlib.rcParams 的键/值对映射。

Path

样式文件的路径,由 rc_params_from_file 加载。

list

样式说明符(str、Path 或 dict)列表,按列表中从第一个到最后一个的顺序应用。

备注

以下 rcParams> 与样式无关,如果在样式规范中找到,将被忽略:

  • backend

  • backend_fallback

  • date.epoch

  • docstring.hardcopy

  • figure.max_open_warning

  • figure.raise_window

  • interactive

  • savefig.directory

  • timezone

  • tk.window_focus

  • toolbar

  • webagg.address

  • webagg.open_in_browser

  • webagg.port

  • webagg.port_retries

matplotlib.style.library#

一个将样式名称映射到定义该样式的 rcParams> 的字典。

此字典应为只读。使用 reload_library> 进行更新。

matplotlib.style.available#

可用样式的名称列表。

此字典应为只读。使用 reload_library> 进行更新。