python - Plotting a 2D heatmap with Matplotlib -
using matplotlib, want plot 2d heat map. data n-by-n numpy array, each value between 0 , 1. (i, j) element of array, want plot square @ (i, j) coordinate in heat map, color proportional element's value in array.
how can this?
the imshow()
function parameters interpolation='nearest'
, cmap='hot'
should want.
import matplotlib.pyplot plt import numpy np = np.random.random((16, 16)) plt.imshow(a, cmap='hot', interpolation='nearest') plt.show()
Comments
Post a Comment