seaborn barplot of grouped data

Question:

This is my dataset:

dataset

I’d like to use seaborn to plot each column, just like pandas would do by default:

plot

Any clue?
Thanks in advance

Asked By: user378147

||

Answers:

You can first stack the data, and then use sns.barplot with hue:

stacks = df.stack().reset_index()

plt.figure(figsize=(10,10))
sns.barplot(x='level_1', y=0, data=stacks, hue='cat')
plt.show()

Output:

enter image description here

Answered By: Quang Hoang
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.