Sorting categorical labels in seaborn chart Sorting categorical labels in seaborn chart pandas pandas

Sorting categorical labels in seaborn chart


Set the order parameter.

plot_income_cat_hours = sns.countplot(x='hours_per_week_grouping',                        hue='income-cat', data=data, order=['place the desired order here'])


You may try the following,

sns.countplot(data = data.sort_values(by="hours_per_week_grouping"),               x= "hours_per_week_grouping", hue= "income-cat")