Small Multiples in matplotlib


In [1]:
%load_ext watermark
%watermark -a 'Hideki Tanaka' -u -d -v -p matplotlib,numpy


Hideki Tanaka 
last updated: 2016-02-23 

CPython 3.5.1
IPython 4.1.1

matplotlib 1.5.1
numpy 1.10.4

In [2]:
%matplotlib inline

In [3]:
import matplotlib.pyplot as plt
import numpy as np

In [4]:
plt.style.use('ggplot')
plt.rc('xtick.major', size=0)
plt.rc('ytick.major', size=0)

In [5]:
data = np.random.rand(10, 10)

In [6]:
interp_methods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16',
                  'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',
                  'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos']

In [7]:
fig = plt.figure(figsize=(12, 6))
cm = plt.cm.get_cmap('jet')

for i in range(18):
    ax = fig.add_subplot(3, 6, i+1)
    im = ax.imshow(data, cmap=cm, interpolation=interp_methods[i])
    ax.set_title(interp_methods[i])
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())

plt.show()



In [8]:
fig.savefig('../images/mpl_small_multiples.png', dpi=80)