首页 > 解决方案 > 实际处理 pyplot.grid() 函数的源代码?

问题描述

我正在尝试跟踪代码以找出 matplotlib 源代码的哪一部分处理此问题:

import matplotlib.pyplot as plt
...
plt.grid(b=True, which='minor', color='#000000', linestyle='--')

我发现了这个:https ://matplotlib.org/3.1.1/_modules/matplotlib/pyplot.html#grid

但它只是返回gca(),我找不到源代码中的哪个代码实际上将次要网格线颜色设置为#000000,它的线样式为--.

gca返回gcf这里:https ://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/pyplot.py#L2204

这会返回,figure但那时我迷路了,找不到在plt.grid()调用函数时设置次要网格线样式的源代码。

(我确实知道/相信可以在此处找到通过 rcParams 处理更改主要网格线样式的源代码:https ://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py )

谢谢!

标签: pythonmatplotlib

解决方案


推荐阅读