python pyplot在matplotlib.style文件中指定虚线网格的密度

标签 python matplotlib

我会问是否有人知道文件 .mplstyle 中是否可能定义虚线网格的密度.. 目前我正在使用一个类来准备我的地 block ,我会尝试创建一个方法mplstyle 文件并像这样使用它: plt.style.use(['mystyle', 'mystyle-vega']) 我找到了几乎所有选项 .. 但是一旦我没有意识到如何指定网格的 dases=(5,9) ,我就找到了将网格设置为 '-- '

编辑 好的,非常感谢!

最佳答案

要通过 rcParameters 设置网格,您可以使用 grid.linestyle 参数。将其设置为您想要的任何值。

import matplotlib.pyplot as plt

plt.rcParams["axes.grid"] = True
plt.rcParams["grid.linestyle"] = (5,9)

plt.gca()
plt.show()

enter image description here

目前是not possible to use such tuples在外部 matplotlibrc 文件中。

关于python pyplot在matplotlib.style文件中指定虚线网格的密度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51580820/

相关文章:

python - pip 不能使用自定义 SSL 证书?

python - 在 Python 中将当前日期添加到指定的小时和分钟

python - 使用日志记录时拆解中的 Pytest 错误

python - Django, 1.9.10 语言匹配查询不存在

python - 停止动画——康威的生命游戏

python - 为什么 mlab 和 scipy.signal 的交叉光谱不同?

Python 和 Smalltalk - 元编程能力比较

python - 如何格式化缺少日期的 x 轴时间序列刻度线

python - Matplotlib set_xticklabels 未对齐

python - 使用 seaborn 在 python 中绘制 3 列的热图