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() 

enter image description here


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -