... matplotlib: subplot


Sometimes you'd like to make figures in a grid. In these scenarios you may find the plt.subplot command useful. A demonstration of this function is listed below.

import numpy as np
import matplotlib.pylab as plt

for i, mu in enumerate([0, 1, 2]):
    for j, sigma in enumerate([0.1, 0.2, 0.3]):
        x = np.random.normal(mu, sigma, (1000,))
        plt.subplot(3, 3, 3 * i + j + 1)
        plt.xlim(-1, 4)

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.