+4 votes
in Programming Languages by (14.6k 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

0 votes
by (25.6k points)

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()

...