how to change the order of factor plot in seaborn

后端 未结 3 536
孤街浪徒
孤街浪徒 2021-01-07 23:02

My data looks like this:

m=pd.DataFrame({\'model\':[\'1\',\'1\',\'2\',\'2\',\'13\',\'13\'],\'rate\':randn(6)},index=[\'0\', \'0\',\'1\',\'1\',\'2\',\'2\'])
         


        
3条回答
  •  -上瘾入骨i
    2021-01-07 23:33

    As @Pablo wrote in his comment and @Archie correctly mentioned in their answer:

    x_order should be replaced by order

    For those who came here looking for a sort solution for kind="count", it is possible to do so:

    sns.catplot(x="model", data=m, kind="count", order=m.model.value_counts().index)

    It's because by default value_counts method will return descending sorted values by count.

提交回复
热议问题