使用pylab生成热图

8 python matplotlib ipython heatmap

我有一个2d数据数组,我想用pylab绘制为热图.我只找到了使用普通点来构建热图的解决方案,但没有找到映射f(x,y) = heat到热图的方法.

PS:ipython很棒,可以和pylab一起做这些东西:)

小智 17

结果很简单:

import pylab as pl
data = pl.random((25,25)) # 25x25 matrix of values
pl.pcolor(data)
pl.colorbar()
pl.show()
Run Code Online (Sandbox Code Playgroud)