Home > Software engineering >  Order seaborn countplot by Month
Order seaborn countplot by Month

Time:01-24

this should be very simple but I'm trying to order a seaborn countplot by Month. The default is in reverse order (latest months first), so I would like to either simply reverse the order or specify the order - ideally I'd like to understand how to do both.

This is the code I have:

sns.countplot(data = cycling ,x = cycling['Date'].dt.strftime('%Y-%m') ) plt.xticks(rotation=45) plt.show()

I tried adding order = cycling['Date'].dt.strftime('%Y-%m') but it just splits the bars further based on how many entries I had for that month. So it goes from this: sns.countplot ordered by date

  • Related