matplotlib中热图的问题

时间:2017-08-27 04:14:54

标签: python matplotlib heatmap

我试图以两种方式在matplotlib中绘制热图:

plt.figure(figsize=(8, 6))
heatmap, xedges, yedges = np.histogram2d(rtl, zs, bins=(128, 128))
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

plt.clf()
plt.xscale('log')

plt.imshow(heatmap, extent=extent)
plt.show()

第二种方式是:

fig, ax = plt.subplots(figsize=(8, 6))

hb = ax.hexbin(rtl, zs, gridsize=50)
ax.axis([min(rtl), max(rtl), min(zs), max(zs)])
plt.show()

但是对于相同的数据,我得到了非常不同的情节。我不明白这里发生了什么。

plot1 plot2

1 个答案:

答案 0 :(得分:1)

如果您仔细查看图片,则两个图表看起来都是一样的。一个是对数刻度,而一个是正常图。