【问题标题】:Clustered Stacked Bar in Python Pandas [closed]Python Pandas 中的聚集堆积条形图 [关闭]
【发布时间】:2017-02-28 12:19:34
【问题描述】:

我创建了一个堆叠条形图,但我希望将它们聚集在一起。和图片一模一样。

想知道这是否可能。

link to picture

【问题讨论】:

    标签: python pandas matplotlib


    【解决方案1】:
    df = pd.DataFrame(dict(Subsidy=[3, 3, 3],
                           Bonus=[1, 1, 1],
                           Expense=[2, 2, 2]),
                      list('ABC'))
    
    df
    

    ax = df[['Subsidy', 'Bonus']].plot.bar(stacked=True, position=1,
                                width=.2, ylim=[0, 8], color=['orange', 'red'])
    df[['Expense']].plot.bar(ax=ax, position=0, width=.2, color=['green'])
    

    【讨论】:

    • 嗨,如果我想使用日期作为列表名称怎么办?
    猜你喜欢
    • 1970-01-01
    • 2020-04-12
    • 2021-10-04
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多