Compositing multiple figures
When examining some data, we might want to see several aspects of it at once. For instance, with population statistics data from one country, we would like to see the male/female age pyramid, the wealth repartition, and the population size per year as three distinct graphics. matplotlib offers the possibility to composite several figures together. Since Version 1.2, the API for this is really convenient. In this recipe, we are going to see how to compose several figures together.
How to do it...
We are going to use the pyplot.subplot2grid()
function as follows:
import numpy as np from matplotlib import pyplot as plt T = np.linspace(-np.pi, np.pi, 1024) grid_size = (4, 2) plt.subplot2grid(grid_size, (0, 0), rowspan = 3, ...
Get matplotlib Plotting Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.