I have a df such as :
data = {
'class': ['First', 'First', 'First', 'Second', 'Second', 'Second', 'Third', 'Third', 'Third'],
'who': ['child', 'man', 'woman', 'child', 'man', 'woman', 'child', 'man', 'woman'],
'survived': [5, 42, 89, 19, 8, 60, 25, 38, 56],
'Percentage': [10.204082, 47.727273, 43.414634, 38.775510, 9.090909, 29.268293, 51.020408, 43.181818, 27.317073]
}
# Create DataFrame
df = pd.DataFrame(data)
class who survived Percentage
0 First child 5 10.204082
1 First man 42 47.727273
2 First woman 89 43.414634
3 Second child 19 38.775510
4 Second man 8 9.090909
5 Second woman 60 29.268293
6 Third child 25 51.020408
7 Third man 38 43.181818
8 Third woman 56 27.317073
Could someone help me to write a code with seaborn where :
I want a barplot grouped by "class" in that order : ["First","Second","Third"] and were the bar plots are also grouped such as : ["child","man","woman"].
In the y axis should be displayed the percentage of survived .
And I would like for each bar to display in their top the actual 'survived' value.
In the end the plot should look like that :
Here is the code I got so far :
# Plot
ax = sns.barplot(x='class', y='Percentage', hue='who', data=data, estimator=sum, ci=None)
ax.set(ylabel='Survived Count', title='Survived Count and Percentage')

As per the duplicate: