Learn seaborn

Statistical data visualization on top of Matplotlib and pandas

15 lessons · 3 hours · 4 levels · covers seaborn 0.13

seaborn is a high-level plotting library that turns pandas DataFrames into informative statistical charts in one call: distributions, relationships, categorical comparisons, regressions and multi-panel facets, with sensible themes and color palettes. Because it draws on Matplotlib, every chart can be fine-tuned with Matplotlib when needed.

Before you start

seaborn builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics5 lessons · 54 min in total
2. PracticalUse it productively at work, with the usual idioms9 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs12 lessons · 2 hours in total
4. ExpertInternals and the edge cases experts know15 lessons · 3 hours in total

The seaborn tree

seabornseaborn and long-form dataseaborn andlong-form dataScatter and line plots with semanticsScatter and line plotswith semanticsDistributions: histplot, kdeplot, ecdfplotDistributions:histplot, kdeplot, ec…Categorical plots: box, violin, bar, stripCategorical plots:box, violin, bar, stripThemes, contexts and color palettesThemes, contextsand color palettesAxes-level vs figure-level functionsAxes-level vsfigure-level functionsAggregation and error barsAggregation anderror barsHeatmaps and pairwise plotsHeatmaps andpairwise plotsRegression plots: regplot and lmplotRegression plots:regplot and lmplotFigures, Axes and pyplotFigures, Axes andpyplotDataFrameDataFrameTitles, labels and legendsTitles, labels andlegendsGrids of plots with subplotsGrids of plots withsubplotsReshaping: pivot, melt, stackReshaping: pivot,melt, stack
Essentials and Practical shown (9 of 15 lessons); the full list is below. Click a lesson to read it.

All 15 lessons, in order

Data and first plots

  1. seaborn and long-form data · Essentials · 10 min

    How seaborn maps DataFrame columns to plot roles like x, y and hue, and why it prefers long-form (tidy) data.

Plot families

  1. Scatter and line plots with semantics · Essentials · 10 min

    Use scatterplot and lineplot with hue, style and size to show how variables relate across groups.

  2. Distributions: histplot, kdeplot, ecdfplot · Essentials · 12 min

    Visualize how a variable is distributed with histograms, kernel density estimates and ECDFs, overall and per group.

  3. Categorical plots: box, violin, bar, strip · Essentials · 12 min

    Compare a numeric variable across categories with box, violin, strip, swarm, bar and count plots.

  4. Heatmaps and pairwise plots · Practical · 12 min

    Draw annotated matrix heatmaps from pivoted data and explore all pairwise relationships with pairplot and jointplot.

  5. Regression plots: regplot and lmplot · Practical · 10 min

    Overlay a fitted regression line with a confidence band, including polynomial, logistic and robust fits.

Themes and palettes

  1. Themes, contexts and color palettes · Essentials · 10 min

    Set the overall look with set_theme, scale for paper or talk with contexts, and choose qualitative, sequential or diverging palettes.

Facets and figure-level plots

  1. Axes-level vs figure-level functions · Practical · 12 min

    Know the difference between functions that draw on one Axes and those that build whole faceted figures, and how to size and save each.

  2. Custom grids with FacetGrid and PairGrid · Advanced · 14 min

    Build your own faceted figures by mapping any plotting function over FacetGrid, PairGrid and JointGrid.

  3. Fine-tuning seaborn with Matplotlib · Advanced · 12 min

    Combine seaborn plots with Matplotlib layouts, legends, ticks and annotations to reach publication quality.

Statistics under the hood

  1. Aggregation and error bars · Practical · 12 min

    Control how lineplot, barplot and pointplot aggregate repeated observations and what their error bars mean.

  2. How seaborn estimates: bootstrap and binning · Expert · 15 min

    Understand exactly how seaborn computes confidence intervals, KDE bandwidths and histogram bins, and how to make results reproducible and fast.

  3. Large data and plotting performance · Expert · 12 min

    Keep seaborn fast and readable on millions of rows by aggregating, binning, sampling and avoiding expensive defaults.

The objects interface

  1. The seaborn.objects interface · Advanced · 15 min

    Build plots declaratively by composing Plot, marks, stats and moves, a grammar-of-graphics style API.

  2. Scales, properties and custom stats · Expert · 16 min

    Control how data maps to visual properties with Scale objects, and extend seaborn.objects with your own Stat or Move.