Categorical scatterplots
Show every observation across one or more categorical variables.
Seaborn · Function
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.
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.
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)| Name | Type | Description |
|---|---|---|
data | DataFrame, Series, dict, array, or list of arrays | Dataset for plotting; the documentation lists DataFrame, Series, dict, array, or list of arrays. |
x, y | vector or key in data | Names of variables or vectors mapped to the horizontal and vertical axes. |
hue | vector or key in data | Grouping variable used to add semantic color distinctions. |
row, col | vector or key in data | Variables used to create row and column facets. |
kind | string | Selects the underlying categorical axes-level function. |
estimator | string or callable | Controls the estimator used within each categorical bin. |
errorbar | string, tuple, or callable | Method and level for uncertainty intervals. |
n_boot | int | Number of bootstrap iterations when bootstrap estimation is used. |
FacetGrid
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.
Show every observation across one or more categorical variables.
Summarize category-wise distributions with quartiles or density-like shapes.
Compare category-level estimates and uncertainty intervals.
Display additional categorical dimensions as separate panels.
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".
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.
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.
stripplotswarmplotboxplotviolinplotboxenplotpointplotbarplotcountplot