Categorical plot

Seaborn basics

2 min read

Published Oct 7 2025


24
0
0
0

ChartsGraphsMatplotlibNumPyPandasPythonSeabornVisualisation

seaborn.catplot() is a high-level figure-level function for creating categorical plots in Seaborn.
It combines the features of several categorical plotting functions — like:

  • sns.stripplot()
  • sns.swarmplot()
  • sns.boxplot()
  • sns.violinplot()
  • sns.barplot()
  • sns.countplot()

…and adds faceting support (multiple subplots based on data subsets).

Essentially, catplot() = categorical plot + easy subplotting (faceting).


Syntax:

sns.catplot(
    data=None,
    x=None,
    y=None,
    hue=None,
    kind="strip",
    col=None,
    row=None,
    order=None,
    hue_order=None,
    col_order=None,
    row_order=None,
    height=5,
    aspect=1,
    palette=None,
    orient=None,
    dodge=True,
    legend=True,
    margin_titles=False,
    **kwargs
)

Parameters:

  • data = DataFrame containing your data
  • x, y = Categorical and numerical variables
  • hue = Adds subgroups (coloured)
  • kind = Type of categorical plot to draw ("strip", "swarm", "box", "violin", "bar", "count", "boxen")
  • col, row = Variables for faceting (creating subplots)
  • order, hue_order = Category ordering
  • palette = Colour scheme
  • height = Height (in inches) of each subplot
  • aspect = Width = height × aspect
  • orient = "v" (vertical) or "h" (horizontal)
  • dodge = Separate hue categories
  • legend = Show or hide legend
  • margin_titles = Add titles on the edges of facets




Basic example

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.catplot(data=tips, x="day", y="total_bill", kind="box")
plt.show()

Creates a boxplot showing the distribution of total_bill for each day.


seaborn cat plot basic example





Kinds of categorical plots

Kind

What It Shows

Equivalent Function

"strip"

Individual data points (with possible jitter)

sns.stripplot()

"swarm"

Non-overlapping points

sns.swarmplot()

"box"

Summary statistics (quartiles, median, outliers)

sns.boxplot()

"violin"

Distribution + density + quartiles

sns.violinplot()

"boxen"

Enhanced boxplot for large datasets

sns.boxenplot()

"bar"

Aggregated values (mean + CI)

sns.barplot()

"count"

Counts of each category

sns.countplot()

You can switch kind to change the plot type — no need to rewrite code.






Faceting: split data into subplots

Faceting = multiple subplots based on different subsets of your data.


Facet by Column:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.catplot(
    data=tips,
    x="day",
    y="total_bill",
    hue="sex",
    col="smoker",
    kind="box",
    palette="Set2"
)
plt.show()

Creates one subplot for smokers and one for non-smokers.


seaborn cat plot col example


Facet by Row:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.catplot(
    data=tips,
    x="day",
    y="total_bill",
    hue="sex",
    row="time",
    kind="violin",
    palette="pastel"
)
plt.show()

One row for Lunch and one for Dinner.


seaborn cat plot row example





Facet by both row and column

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.catplot(
    data=tips,
    x="day",
    y="total_bill",
    hue="sex",
    col="smoker",
    row="time",
    kind="box",
    palette="coolwarm"
)
plt.show()

Grid of subplots by both smoker and time.


seaborn cat plot row and col example

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact