【发布时间】:2019-09-29 14:39:16
【问题描述】:
total_group_sum.unstack().plot(kind='bar')
我可以绘制我的条形图,但是现在我想在它上面画一条水平平均线。我尝试使用axhline(),但出现错误:
ValueError:Series 的真值不明确。使用a.empty, a.bool()、a.item()、a.any() 或 a.all()。
如何在现有条形图上绘制水平平均线?
total_group_sum.unstack().plot(kind='bar')
<IMAGE OF BAR GRAPH (I AM NOT ABLE TO POST PHOTO HERE)>
mean = total_group_sum.mean()
plt = total_group_sum.unstack().plot(kind='bar')
plt.axhline(mean)
ValueError: The truth value of a Series is ambiguous. Use a.empty,
a.bool(), a.item(), a.any() or a.all().
PS - 我正在使用 jupyter 笔记本
【问题讨论】:
-
请发布您的数据样本
标签: pandas matplotlib plot bar-chart mean