【发布时间】:2017-08-21 22:28:17
【问题描述】:
我可以使用以下代码创建 n×n 热图,例如让 n 为 10:
random_matrix = np.random.rand(10,10)
number = 10
incrmnt = 1.0
x = list(range(1,number +1))
plt.pcolormesh(x, x, random_matrix)
plt.colorbar()
plt.xlim(1, number)
plt.xlabel('Number 1')
plt.ylim(1, number)
plt.ylabel('Number 2')
plt.tick_params(
axis = 'both',
which = 'both',
bottom = 'off',
top = 'off',
labelbottom = 'off',
right = 'off',
left = 'off',
labelleft = 'off')
我想在 x 轴和 y 轴附近添加一个 2 行热图,例如 row1 = np.random.rand(1,10) 和 col1 = np.random.rand(1,10)。
这是我想要制作的示例图片:
提前致谢。
【问题讨论】:
-
还有一个很similar question询问如何在不同位置“剪切”热图,以防有人感兴趣。
标签: python matplotlib heatmap