seaborn countplot code example
Example 1: display values on countplot
plt.figure(figsize=(12,8))
ax = sns.countplot(x="AXLES", data=dfWIM, order=[3,4,5,6,7,8,9,10,11,12])
plt.title('Distribution of Truck Configurations')
plt.xlabel('Number of Axles')
plt.ylabel('Frequency [%]')
for p in ax.patches:
ax.annotate('%{:.1f}'.format(p.get_height()), (p.get_x()+0.1, p.get_height()+50))
Example 2: countplot in pandas
>>> import seaborn as sns
>>> sns.set_theme(style="darkgrid")
>>> titanic = sns.load_dataset("titanic")
>>> ax = sns.countplot(x="class", data=titanic)
Example 3: seaborn pairplot
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
>>> iris = sns.load_dataset("iris")
>>> g = sns.pairplot(iris)
Example 4: countplot for different classes in a column
>>> ax = sns.countplot(x="who", data=titanic, palette="Set3")
Example 5: countplot
A countplot is kind of likea histogram or a bar graph for some categorical area. ... You put this statement in if you are using an editor such as jupyter notebooks so that you can see the graph output in the editor. Seaborn already has built-in data sets. One data set that can be used is tips.
Example 6: seaborn countplot
import pandas as pd
import seaborn as sns
df = pd.DataFrame()
sns.countplot(data=df)