Count plots
Seaborn basics
1 min read
This section is 1 min read, full guide is 42 min read
Published Oct 7 2025, updated Aug 17 2026
24
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
ChartsGraphsMatplotlibNumPyPandasPythonSeabornVisualisation
seaborn.countplot() is used to count the number of occurrences of each category in a variable and display those counts as bars.
It’s basically like a barplot of counts, except you don’t need to compute the counts yourself — Seaborn does it automatically.
Syntax:
sns.countplot( data=None, x=None, y=None, hue=None, order=None, hue_order=None, palette=None, orient=None, dodge=True, width=0.8, **kwargs)Parameters:
data= DataFrame containing the datax,y= Variable(s) for categories (only one is usually needed)hue= Adds subcategories (grouped bars)order/hue_order= Order of categories/subcategoriespalette= Colour paletteorient= "v" (vertical) or "h" (horizontal)dodge= Separate hue bars side by side (default: True)width= Bar width
Basic example
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot(data=tips, x="day")plt.show()This shows how many records (meals) occurred on each day of the week.

Add hue (subgroups)
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot(data=tips, x="day", hue="sex")plt.show()- Bars are split by sex.
- Each day shows two bars — one for each group in
sex.

Horizontal bars
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot(data=tips, y="day", hue="sex", orient="h")plt.show()Flips the bars horizontally — helpful for long category names.

Specify category order
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot( data=tips, x="day", order=["Sun", "Sat", "Fri", "Thur"])plt.show()Controls the order of bars along the x-axis.

Customise colours and style
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot( data=tips, x="day", hue="sex", palette="coolwarm", edgecolor="black", width=0.7)plt.show()palette="coolwarm"→ colourful schemeedgecolor="black"→ outlines barswidth=0.7→ slightly thinner bars

Count of multiple variables (via hue)
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.countplot(data=tips, x="smoker", hue="sex")plt.show()Shows how many male vs. female smokers and non-smokers there are.
