【问题标题】:how to order the bars in the order as they receive in matplotlib in python?如何按照它们在 python 中的 matplotlib 中收到的顺序对条进行排序?
【发布时间】:2018-02-08 13:34:33
【问题描述】:

如何将频率图中的条按0、1、2、3、4的顺序排列,而不是下图所示的最高频率?

这是我使用的代码:

train_df.Fedu.value_counts().plot(kind='bar', alpha=0.6)
plt.title("Distribution of Father's  education")

【问题讨论】:

    标签: python python-2.7 python-3.x pandas matplotlib


    【解决方案1】:

    使用sort_index:

    train_df.Fedu.value_counts().sort_index().plot(kind='bar')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-03
      • 2021-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多