Visualizing a matrix with imshow

The following code compares two interpolation schemes, 'bilinear' (which is the default on many new installations of Matplotlib and for a small array is blurry) and 'nearest' which should look "blocky" (i.e. more faithful to the data).

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm

# Make an array with ones in the shape of an 'X'
a = np.eye(10,10)
a += a[::-1,:]

fig = plt.figure()
ax1 = fig.add_subplot(121)
# Bilinear interpolation - this will look blurry
ax1.imshow(a, cmap=cm.Greys_r)

ax2 = fig.add_subplot(122)
# 'nearest' interpolation - faithful but blocky
ax2.imshow(a, interpolation='nearest', cmap=cm.Greys_r)

plt.show()

Matrix visualization