Grouped bar chart — how to make sns respect order

2019-08-18 00:07发布

I have a multilevel data frame, sorted by values on level=1

my data

I want to make a grouped bar plot. When I do

ax = sns.barplot(ax=ax, x="level0", y="values",
             hue="level1", data=data)

Sns decides to sort index by level1.

result

Is there a way to make sns respect the order of rows when making grouped bar plots?

标签: seaborn
1条回答
smile是对你的礼貌
2楼-- · 2019-08-18 00:53

As per the comment from @ImportanceOfBeingErnest, you can use the order and hue_order parameters to control in which order the bars appear along the x-axis.

查看更多
登录 后发表回答