相关疑难解决方法(0)

旋转轴标签放置不正确(matplotlib)

我想绘制一个带有旋转标签的相关矩阵。但是,标签错位,如下所示。我试图查看Matplotlib Python Barplot: Position of xtick 标签在彼此之间有不规则的空间,但我不能让它在我的情况下工作,因为它建立在条形图的布局上。使用以下代码添加标签:

    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);
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

python matplotlib

4
推荐指数
1
解决办法
4279
查看次数

标签 统计

matplotlib ×1

python ×1