logo

... matplotlib.


For quick plotting, you can't go wrong with matplotlib.


Episode Notes

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

plt.figure(figsize=(7,7))
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.hist(x)
        plt.xlim(-1, 4)

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

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