【问题标题】:What is the pyplot equivalent of seaborn barplot?seaborn barplot 的 pyplot 等价物是什么?
【发布时间】:2019-08-05 19:07:56
【问题描述】:

我想转换这个条形图:

sns.barplot(x='Pclass', y='Survived', data=train_df)

使用 Pandas 数据框或 pyplot 中的内置绘图功能 如何将此 seaborn barplot 转换为 pyplot 条形图?

【问题讨论】:

    标签: python pandas matplotlib seaborn


    【解决方案1】:

    使用pandas 绘图功能:

    train_df.plot(x='Pclass', y='Survived', kind='bar')
    

    【讨论】:

      【解决方案2】:

      pyplot(import matplotlib.pyplot as plt):

      plt.bar(x='Pclass', height='Survived', data=train_df)
      

      【讨论】:

        猜你喜欢
        • 2020-07-21
        • 2014-05-08
        • 2014-06-12
        • 1970-01-01
        • 2022-11-28
        • 1970-01-01
        • 2018-07-10
        • 2023-04-10
        • 2011-01-19
        相关资源
        最近更新 更多