O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

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

Manually rendering multiple plots in a single chart

It is often useful to contrast data by displaying multiple plots next to each other. We have seen that pandas does this automatically for several types of graphs. It is also possible to manually render multiple plots on the same canvas.

To render multiple subplots on a canvas with matplotlib, make multiple calls to plt.subplot2grid(). Each time pass the size of the grid the subplot is to be located on (shape=(height, width)) and the location on the grid of the upper-left location of the subplot (loc=(row, column)). The dimensions are in the overall number of columns and not pixels.

The return value from each call to plt.subplot2grid() is a different AxesSubplot object that can be used to ...

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