+4 votes
in Programming Languages by (77.2k points)

I have added both major and minor grids to my plot, but the plot does not display them. How can I display grids.

Here is my code:

ax.grid(b=True, which='major', color='b', linestyle='-')
ax.grid(b=True, which='minor', color='r', linestyle='--')

1 Answer

+2 votes
by (354k points)
selected by
 
Best answer

To display minor ticks on the axes, you need to use minorticks_on(self).

Make the following change and it will display grids.

ax.grid(b=True, which='major', color='b', linestyle='-')
ax.grid(b=True, which='minor', color='r', linestyle='--')
ax.minorticks_on()


...