g = np.floor(np.random.random((100, 100)) + 0.5)
plt.subplot(211)
plt.imshow(g)
plt.subplot(212)
plt.imshow(g, cmap='Greys', interpolation='nearest')
plt.savefig('blkwht.png')
plt.show()
Plot a black-and-white binary map in matplotlib