Plotting a 2D heatmap

The imshow() function with parameters interpolation='nearest' and cmap='hot' should do what you want.

Please review the interpolation parameter details, and see Interpolations for imshow and Image antialiasing.

import matplotlib.pyplot as plt
import numpy as np

a = np.random.random((16, 16))
plt.imshow(a, cmap='hot', interpolation='nearest')
plt.show()

A sample color map produced by the example code

Leave a Comment