使用matplotlib的热图 - 意外的图像

时间:2018-01-26 12:02:23

标签: python matplotlib heatmap

我试图想象一下热图的dirichlet分布,但是我得到了一个意想不到的图像。你能解释一下吗?

我的代码是:

a = np.random.dirichlet(alpha = [0.3, 0.7], size = 1000)
plt.imshow(a, cmap='hot', interpolation='nearest')
plt.show()

图片是:

enter image description here

您的建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

数组a中的行数比列数多得多。

可能您希望以不相等的宽高比显示图像。对于那套

plt.imshow(a, aspect="auto")