Home > Enterprise >  Seaborn: Sorting countplot by ascending
Seaborn: Sorting countplot by ascending

Time:11-16

How, can I sort this plot to show from biggest to lowest? I tried to use sort_values but does not work

plt.figure(figsize=(15,8))
sns.countplot(x='arrival_date_month',data=df.sort_values('arrival_date_month',ascending=False))
plt.xticks(rotation=45)

enter image description here

CodePudding user response:

The default ordering for a column of type string is the order of occurrence in the dataframe.

You can set a fixed order, either by using the order= keyword, or by making the column ordering sns.countplot from high to low

  • Related