I have a dataframe data_gender:
| gender | math_score | reading_score | writing_score | avg_score |
|---|---|---|---|---|
| female | 63.63 | 72.61 | 72.47 | 69.57 |
| male | 68.73 | 65.47 | 63.31 | 65.84 |
and I want to make a seaborn barplot that looks like this plot that I made with matplotlib with simple line
data_gender.plot.bar(figsize=(8,6))
How would one do it with seaborn?
>Solution :
You can reshape with melt and pass the data to sns.barplot:
sns.barplot(data=data_gender.melt(id_vars='gender',
value_name='score', var_name='course'),
x='gender', y='score', hue='course')
output:
