I have a seaborn countplot which I have included the 'hue parameter' this is how the plot looks like:
Male
Total count for male = 240 669, Total count for active male = 130 856, Total count for churn male = 109 813
M (Active) --- 130856/240669 = 54.4% and M (Churn) --- 109813/240669 =45.6%
Female
Total count for female = 198 408, Total count for active female = 111 107, Total count for churn female = 87 301
So F (Active) --- 111107/198408 = 56% and F(Churn) --- 87301/198408 =44%
I want the total percentage of each gender to total 100% instead of the percentages given in the attached plot.
This is the code i used:
plt.figure(figsize=(10,6))
colours = ['b','red']
ax = sns.countplot(df.GENDER,hue=df['Status'],order =
df['GENDER'].value_counts().index,palette=colours)
plt.title("GENDER VS STATUS",fontsize=15)
plt.tight_layout()
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
total = float(len(df))
for p in ax.patches:
height = p.get_height()
ax.text(p.get_x()+p.get_width()/2.,
height + 3,
'{0:.1%}'.format(height/total),
ha="center", fontsize=15)
print(df['GENDER'].value_counts(normalize=True))