【发布时间】:2022-01-23 14:01:14
【问题描述】:
我有以下代码:
fig, ax = plt.subplots()
single_customer_g['Size_GB'] = round(single_customer_g['Size_GB'] / 1024, 2)
single_customer_g = single_customer_g.pivot('Date', 'Vault', 'Size_GB')
single_customer_g.plot.bar(stacked=True, rot=1, figsize=(15, 10), ax=ax, zorder=3)
for c in ax.containers:
labels = [round(v.get_height(), 2) if v.get_height() > 0 else 0 for v in c]
ax.bar_label(c, labels=labels, label_type='center')
我正在尝试在每列顶部添加总数字作为标签,但无法弄清楚。我尝试了多个示例,但到目前为止没有任何效果。
【问题讨论】:
标签: python pandas matplotlib