相关疑难解决方法(0)

Matplotlib:检查网格是否打开?

Matplotlib有一个非常简单的方法来切换图形上的网格线:

from matplotlib.figure import Figure
fig = Figure()
ax = fig.add_subplot(111)
ax.grid(True)
Run Code Online (Sandbox Code Playgroud)

但是它似乎没有确定网格状态的任何方法(打开/正确或关闭/错误)?

一看源代码显示,埋在Axis类中,有私有变量:self._gridOnMinorself._gridOnMajor

可以通过以下方式访问这些文件:

ax.xaxis._gridOnMinor
ax.yaxis._gridOnMinor
Run Code Online (Sandbox Code Playgroud)

依此类推...但是由于这些被指定为私有,因此我对此有些谨慎。

这真的是检查网格是打开还是关闭的唯一方法?

python grid matplotlib

6
推荐指数
1
解决办法
479
查看次数

标签 统计

grid ×1

matplotlib ×1

python ×1