首页 > 解决方案 > 如何用每个条的百分比绘制条形图

问题描述

我有 x 列的数据框 df , x 列有很多我想绘制的值 bar 。将 bin 中的数据从 0 到 1 2 到 3 ,4 到 5. 每个 bin 条和每个条的百分比

我现在试过了,但我不知道如何给出每个栏的百分比

out = pd.cut(xz, bins=[0,1, 2, 6,], include_lowest=True)
ax = out.value_counts(sort=False).plot.bar(rot=0, color="b", figsize=(6,4))

标签: python-3.xpandasmatplotlib

解决方案


推荐阅读