【问题标题】:Impossible to find proper documentation for matplotlib configuration file .mplstyle无法找到 matplotlib 配置文件 .mplstyle 的正确文档
【发布时间】:2021-05-05 10:03:08
【问题描述】:

我正在为我的论文制作标准绘图格式,使用 matplotlib 及其内置 plt.style.use() 以及我自己制作的自定义 .mplstyle 文件。

我遇到的两个问题:

  1. 在寻找我想要调整的选项时,我找不到搜索 mplstyle 格式原生选项的方法。有时这些与标准 matplotlib 函数或某些函数中的参数相同。但是有时候应该改的mplstyle选项的名字完全不一样,我只能在开源标准mplstyle-files(https://github.com/matplotlib/matplotlib/tree/master/lib/matplotlib/mpl-data/stylelib)中通过ctrl-f-ing找到它

  2. 每当我找到要更改的参数时,我如何知道将其更改为哪个值?我想有机会列出可能的设置选项。前任axes.autolimit_mode,我找到的唯一选项(寻找了很长时间)是'data'(默认)和'round_numbers',但是如果我不喜欢这两个怎么办?必须有更多的选择......

我发现的类似问题的唯一答案是查看指南 (https://matplotlib.org/stable/tutorials/introductory/customizing.html),但这似乎并不包括所有可能的选项(或值)。

【问题讨论】:

    标签: python matplotlib customization


    【解决方案1】:

    要查找参数的可能值,您需要阅读 matplotlib/rcsetup.py,因为 rcParams 的唯一完整文档是 matplotlibrc。 所有参数及其验证器(或可能的值)都在_validators in matplotlib/rcsetup.py 中定义。

    _validators = {
        ...
        "axes.autolimit_mode": ["data", "round_numbers"]
        "axes.xmargin": _range_validators["0 <= x <= 1"],
        "axes.ymargin": _range_validators["0 <= x <= 1"],
        'axes.zmargin': _range_validators["0 <= x <= 1"],
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-18
      • 2018-03-01
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      • 2021-03-27
      • 1970-01-01
      相关资源
      最近更新 更多