I have a large pandas dataframe like this:
In:
d = {'type': ['type 1', 'type 2', 'type 2', 'type 3', 'type 1', 'type 4', 'type 5', 'type 6', 'type 6', 'type 7' ], 'value': ['yes', 'no', 'yes', 'no', 'yes', 'no', 'yes','no', 'yes', 'no']}
df = pd.DataFrame(data=d)
df
Out:
type value
0 type: 1 yes
1 type: 2 no
2 type: 2 yes
3 type: 3 no
4 type: 1 yes
5 type: 4 no
6 type: 5 yes
7 type: 6 no
8 type: 6 yes
9 type: 7 no
How can I create an horizontal barplot with the percentage of yes/no values in each bar? So far I tried to:
sns.barplot(x='type', y='value', data=df, orient = 'h')
However, I only get the bars with no percentage of the distribution for each yes/no value. How can I draw it in the same bar without splitting it? For example:
In the above example, the total count of yes/no is in the x axis.