pythonpandasvisualizationseaborn

how to stop seaborn visualisation sorting the values on the X axis of a bar chart


I have a column in a pandas dataframe called month_name which contains some months of the year.

I have tried feeding this data to seaborn visualisation library as both an object and categorical datatype.

I have also tried sorting the list before I pass it to seaborn library. In Both Instances the resulting graph looks like (with the month_name out of order:

         150           105                   _ 147_
Y-amount 100   47     ____     38    33      |    |
         50  ____     |   |  _____  ____     |    |
         0   |   |    |   |  |    | |   |    |    |
             |   |    |   |  |    | |   |    |    |
                     X-month_name
             August   July   June  October  September

How do I get the month_names to appear in the correct order

And have the actual exact value on top of the bar like in the year example over here which is just above the DOT PLOT example


Solution

  • This is an issue with the new pd.Categorical type in seaborn, which is currently not supported, but is slated for addition in version 0.6.0. See this github issue: https://github.com/mwaskom/seaborn/issues/361