使用Python在我的条形图上显示百分比

时间:2020-04-17 10:25:51

标签: python seaborn

我想知道如何在计数表中增加百分比?

例如df:

Name, Gender, Age
John, Male, 35
Eric, Male, 30
Jo, Female, 34
Ann, Female, 40
Lin, Male, 43
Harry, Male, 28
Max, Not disclosed, 30

我将条形图绘制为

plt.title("Bar chart of Gender")

ax = sns.countplot(x = 'Gender',
                   data = df, 
                   palette = ['blue' , 'red'])
ax.set(xlabel='Gender', ylabel='Total Number')

my current barchart

有没有一种方法可以将百分比也添加到这3个小节中?

0 个答案:

没有答案
相关问题