how to change the order of factor plot in seaborn

后端 未结 3 540
孤街浪徒
孤街浪徒 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:37

    Your update to the post shows the correct way to do it, i.e. you should pass a list of x values to order in the order you want them plotted. The default for numeric data is to plot in sorted order, so if you have numeric values it's best to keep them as integers or floats instead of strings, so they will be in "natural" order.

提交回复
热议问题