O'Reilly logo

Python Data Visualization Cookbook by Igor Milovanović

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing grids

A grid is usually handy to have under lines and charts as it helps the human eye spot differences in pattern and compare plots visually in the figure. To be able to set up how visibly, how frequently, and in what style the grid is displayed—or whether it is displayed at all—we should use matplotlib.pyplot.grid.

In this recipe we will be learning how to turn the grid on and off, and how to change the major and minor ticks on a grid.

Getting ready

The most frequent grid customization is reachable in the matplotlib.pyplot.grid helper function.

To see the interactive effect of this, you should run the following under ipython –pylab. The basic call to plt.grid() will toggle grid visibility in the current interactive session started by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required