【问题标题】:plot dataframe kind= line with axis labels绘制数据框类型 = 带有轴标签的线
【发布时间】:2016-03-11 09:11:35
【问题描述】:

我已经asked about labeling the axes 得到了让我对当时的数据感到满意的答案。但现在我正在尝试使用kind=line 绘制数据框,以更好地评估我的价值观。所以我正在使用这些 pandas 方法,它们对kind=line 的工作方式与kind=bar 的工作方式不同,尽管不提供轴的标签。所以我的数据框:

    name          Homework_note    Class_note     Behavior_note
    Alice Ji      7                6                 6
    Eleonora LI   2                5                 4
    Mike The      6                5                 3
    Helen Wo      5                3                 5

我使用的脚本:

    df=pd.read_csv(os.path.join(path,'class_notes.csv'), sep='\t|,',  engine='python')
    df.columns=['name', 'Homework_note', 'Class_note', 'Behavior_note']
    ax=df.plot(kind='line', x='name', color=['red','blue', 'green'], figsize=(400,100))
    ax.set_xlabel("Names", fontsize=56)
    ax.set_ylabel("Notes", fontsize=56) 
    ax.set_title("Notes evaluation", fontsize=79)
    plt.legend(loc=2,prop={'size':60})
    plt.savefig(os.path.join(path,'notes_names.png'), bbox_inches='tight', dpi=100)

我还可以添加什么来在轴(x 和 y)上放置标签?我更喜欢使用这些 pandas 方法,因为我发现它们更适合使用数据框,但我还没有找到在使用这种类型的绘图时放置标签的方法line

【问题讨论】:

    标签: python pandas matplotlib plot axis-labels


    【解决方案1】:

    标签将显示为较小的figsize (in inches!)。关于传说,请看here

    【讨论】:

      猜你喜欢
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 2012-05-23
      • 1970-01-01
      相关资源
      最近更新 更多