Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Seaborn · Function

catplot

Figure-level interface for categorical plots, combining several axes-level plot types with FacetGrid-based faceting. The kind argument selects the representation, and the returned grid supports further customization.

How it works

Pass a long-form dataset and identify categorical and numerical variables with named arguments such as x, y, and hue. The kind argument chooses the underlying categorical plot, while row and col can create facets; the returned FacetGrid can be customized after plotting.

Syntax

seaborn.catplot(*, x=None, y=None, hue=None, data=None, row=None, col=None, kind='strip', estimator='mean', errorbar=('ci', 95), n_boot=1000, units=None, weights=None, seed=None, order=None, hue_order=None, row_order=None, col_order=None, col_wrap=None, height=5, aspect=1, log_scale=None, native_scale=False, formatter=None, orient=None, color=None, palette=None, hue_norm=None, legend='auto', legend_out=True, sharex=True, sharey=True, margin_titles=False, facet_kws=None, ci='deprecated', **kwargs)

Parameters

NameTypeDescription
dataDataFrame, Series, dict, array, or list of arraysDataset for plotting; the documentation lists DataFrame, Series, dict, array, or list of arrays.
x, yvector or key in dataNames of variables or vectors mapped to the horizontal and vertical axes.
huevector or key in dataGrouping variable used to add semantic color distinctions.
row, colvector or key in dataVariables used to create row and column facets.
kindstringSelects the underlying categorical axes-level function.
estimatorstring or callableControls the estimator used within each categorical bin.
errorbarstring, tuple, or callableMethod and level for uncertainty intervals.
n_bootintNumber of bootstrap iterations when bootstrap estimation is used.

Returns

FacetGrid

Key points

  • Use catplot when you want a complete figure-level categorical visualization organized through a FacetGrid.
  • Choose the categorical representation by setting kind to the desired axes-level plotting function.
  • With no kind specified, catplot uses a strip plot to show individual observations across categories.
  • A box plot is available through kind="box" for summarizing distributions by category.
  • Use kind="point" when the categorical display should use point-based estimates.
  • Keep the returned grid when you need post-plot customization or additional layers.

Common mistakes

  • Use long-form data with variable names for x, y, hue, and related mappings rather than relying on wide-form inputs.
  • Options that are specific to the selected plot type are forwarded to that underlying axes-level function, so consult its documentation.

Example: Grouped categorical plot

import seaborn as sns

penguins = sns.load_dataset("penguins")
g = sns.catplot(
    data=penguins,
    kind="bar",
    x="species",
    y="body_mass_g",
    hue="sex",
    errorbar="sd",
)
g.set_axis_labels("Species", "Body mass (g)")

Loads a dataset and draws a figure-level grouped bar plot, then labels its axes.

When to use it

Categorical scatterplots

Show every observation across one or more categorical variables.

Distribution comparison

Summarize category-wise distributions with quartiles or density-like shapes.

Estimate plots

Compare category-level estimates and uncertainty intervals.

Faceted categorical analysis

Display additional categorical dimensions as separate panels.

Interview questions

QWhat is catplot, and how does kind affect it?

catplot is a figure-level interface that draws categorical plots onto a FacetGrid. It provides one entry point for several categorical representations, selected with kind.

Follow-up: How would you display a categorical distribution instead of individual observations? Use kind="box", kind="violin", or kind="boxen".

QWhat plot types can catplot create?

The default kind is "strip", which produces a categorical scatterplot. Other supported choices include "swarm", "box", "violin", "boxen", "point", "bar", and "count".

Follow-up: Which kind shows estimated values with uncertainty? Use "point" or "bar", whose behavior and options are supplied by their underlying plotting functions.

QWhat does catplot return, and why is that useful?

catplot returns the FacetGrid containing the plot. That object can be used after plotting to adjust supporting plot details or add additional layers.

Follow-up: How can higher-dimensional categorical relationships be shown? Supply row or col faceting variables, optionally using col_wrap to wrap columns.

  • stripplot
  • swarmplot
  • boxplot
  • violinplot
  • boxenplot
  • pointplot
  • barplot
  • countplot

Source: seaborn.catplot — seaborn 0.13.2 documentation. Checked 2026-10-15.