【发布时间】:2015-03-23 15:36:40
【问题描述】:
我想绘制一个带有旋转标签的相关矩阵。但是,标签放错了位置,如下所示。我试图查看Matplotlib Python Barplot: Position of xtick labels have irregular spaces between eachother,但我无法让它在我的情况下工作,因为它建立在条形图的布局之上。使用以下代码添加标签:
fig = plt.figure()
ax1 = fig.add_subplot(111)
varLabels = ['n_contacts', 'n_calls', 'n_texts', 'dur_calls', 'morning', 'work-hours', 'evening', 'night', 'weekdays', 'friday', 'saturday', 'sunday']
ax1.set_xticks(np.arange(0,12))
ax1.set_yticks(np.arange(0,12))
ax1.set_xticklabels(varLabels, rotation=45);
ax1.set_yticklabels(varLabels, rotation=45);
【问题讨论】:
-
我觉得它们很好。对于每个“刻度”,单词的中心对齐,正如您在旋转时所期望的那样(当您围绕单词的中心旋转时)。
-
如果刻度在脊椎/轴的两侧,连接可能会更清晰。
标签: python matplotlib