Grouped bar chart — how to make sns respect order of rows?

老子叫甜甜 提交于 2019-12-13 04:11:40

问题


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

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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/45987198/grouped-bar-chart-how-to-make-sns-respect-order-of-rows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!