This functionality is not built in seaborn.countplot
, as far as I know - the parameter order
accepts only a list of lines for categories and leaves the order logic to the user.
value_counts()
, DataFrame. ,
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style='darkgrid')
titanic = sns.load_dataset('titanic')
sns.countplot(x = 'class',
data = titanic,
order = titanic['class'].value_counts().index)
plt.show()
