Matplotlib has a very easy way to switch grid lines to a shape:
from matplotlib.figure import Figure fig = Figure() ax = fig.add_subplot(111) ax.grid(True)
But he has no way to determine the state of the grid (on / True or off / False)?
A look at the source code shows that it is similar to the Axis class, there are private variables: self._gridOnMinor and self._gridOnMajor
You can access them using:
ax.xaxis._gridOnMinor ax.yaxis._gridOnMinor
and so on ... but since they are assigned as private, I am a little wary of this.
Is this really the only way to check if the grid is turned on?
jramm source share