Python Pandas 中的聚集堆积条形图 [关闭]
Posted
技术标签:
【中文标题】Python Pandas 中的聚集堆积条形图 [关闭]【英文标题】:Clustered Stacked Bar in Python Pandas [closed] 【发布时间】:2017-02-28 12:19:34 【问题描述】:我创建了一个堆叠条形图,但我希望将它们聚集在一起。和图片一模一样。
想知道这是否可能。
link to picture
【问题讨论】:
【参考方案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'])
【讨论】:
嗨,如果我想使用日期作为列表名称怎么办?以上是关于Python Pandas 中的聚集堆积条形图 [关闭]的主要内容,如果未能解决你的问题,请参考以下文章