【发布时间】:2015-07-19 17:39:11
【问题描述】:
我正在尝试绘制一个相关矩阵,而不是作为标签的 bin 编号(请参阅 y 轴标签),我想要物理的实际单位(x 轴标签)。不幸的是,我无法将 xticks 与箱的中心对齐,我不明白为什么我在矩阵的每一列都没有标签。
下面的代码生成图形:
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
labels =['', '0.13','0.20','0.32','0.50','0.79','1.26','2.00','3.16','5.01']
plt.xticks(range(len(labels)+1), labels, size='small')
#The '+1 in range seems needed as if I don't include it the first label is not displayed at all
plt.imshow(np.corrcoef(bootstrap_samples_matrix.transpose()), interpolation='nearest', cmap=plt.cm.Reds, extent=(0.5,10.5,0.5,10.5), align="center")
plt.colorbar()
【问题讨论】:
标签: python matplotlib label axes