Skip to main content
Albero Academy

Histograms

Distributions with grouping, stacking and automatic binning.

Distribution Plots8 min

sns.histplot shows the distribution of a variable, with the grouping and stacking that make comparing subgroups effortless — and smarter default bin choices than raw Matplotlib.

Basic & grouped

histplot with hue
sns.histplot(data=penguins, x="flipper_length_mm", bins=20)
sns.histplot(data=penguins, x="flipper_length_mm",
hue="species", # a coloured histogram per species
multiple="stack") # stack, dodge, layer, or fill

The multiple= modes

When you group with hue, multiple= decides how the groups are arranged: "layer" (overlap, default), "stack", "dodge" (side by side), or "fill" (100% proportions).

Key takeaways

  1. 01sns.histplot shows a variable's distribution with smart default binning.
  2. 02hue splits the histogram by group; multiple= sets layer/stack/dodge/fill.
  3. 03kde=True overlays a smooth density curve.
  4. 04Set bins= or binwidth= to control the bins.

Finished this chapter?

Mark it complete to track your progress through Seaborn.