Seaborn Tutorial
Learn Seaborn step by step: 38 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- Introduction to Seaborn Meet seaborn, the Python library for statistical graphics. See how it builds on Matplotlib and pandas, what it can draw, and how one line replaces dozens.
- Installing Seaborn and Your First Plots Install seaborn with pip or conda, import it the standard way, set a theme, and draw your first scatter, histogram and bar plots from a DataFrame.
- Figure-Level vs Axes-Level Functions Understand the key design idea in seaborn: axes-level functions draw on one Axes, figure-level functions like relplot, displot and catplot manage a whole figure.
Data and Figure Basics
- Tidy Data: Long-Form vs Wide-Form Tables Learn how seaborn reads long-form (tidy) and wide-form data, and how to reshape tables with melt and pivot so every plot call is simple.
- Datasets and load_dataset Use seaborn's example datasets (tips, penguins, iris, flights), read your own CSV files with pandas, set categorical order and handle missing values.
- Mapping Data to Color, Size and Style Learn how seaborn maps columns to color (hue), size and marker style, how categorical and numeric variables differ, and how to control palettes, order and legends.
- Saving Seaborn Figures Save seaborn plots to PNG, SVG or PDF with savefig, control DPI and transparency, avoid cropped labels with bbox_inches, and save FacetGrid figures.
Distributions
- Distributions: Visualizing One Variable Learn what a distribution is and how seaborn's displot draws histograms, KDE curves and ECDFs. Read shape, center, spread, skew and outliers from a plot.
- Histograms with histplot Master seaborn histplot: choose bins and binwidth, switch stat to density or percent, add a KDE curve, compare groups with hue, multiple and element, and use log scales.
- Density Curves with kdeplot Draw smooth density curves with seaborn kdeplot: how a KDE works, bandwidth with bw_adjust, fill, hue, cut and clip, cumulative curves and common pitfalls.
- ECDF and Rug Plots Use seaborn ecdfplot to read percentiles and compare groups without bins, and rugplot to mark every observation. Includes complementary ECDFs and combined plots.
- Two Variables: Bivariate Distributions Visualize two variables at once with seaborn histplot and kdeplot using x and y: 2D histograms, density contours, levels, thresholds, color bars and hue.
Relational and Categorical Plots
- Scatter Plots with scatterplot Draw scatter plots with seaborn scatterplot and relplot: read relationships and correlation, color by group, handle overplotting, add facets and a regression line.
- Bubble Plots: Adding a Third Variable with Size Create bubble plots in seaborn by mapping a numeric column to marker size, tune the size range, avoid misleading bubbles, add labels and combine with hue.
- Line Plots with lineplot Use seaborn lineplot to show trends: aggregation of repeated measurements, confidence intervals, hue and style groups, markers, sorting and relplot facets.
- Categorical Plots: Choosing the Right One Overview of seaborn categorical plots: strip, swarm, box, boxen, violin, bar, count and point. Learn catplot, the kind argument, and how to pick by question.
- Strip and Swarm Plots Use seaborn stripplot and swarmplot to show every observation per category. Control jitter, dodge, hue, size and overlay points on box or violin plots.
- Box, Boxen and Violin Plots Read and draw seaborn box plots, boxen (letter-value) plots and violin plots: quartiles, whiskers, outliers, split violins, hue, inner marks and bandwidth.
- Bar, Count and Point Plots Draw summaries per category with seaborn barplot, countplot and pointplot: means with confidence intervals, counts, hue groups, ordering, labels and pitfalls.
Regression and Matrices
- Regression Plots with regplot and lmplot Draw scatter plots with a fitted regression line and confidence band using regplot and lmplot, add one line per group, and fit polynomial and logistic models.
- Residual Plots and Checking Model Fit Use residplot to see what a regression line misses: spot curvature, uneven spread and outliers, and compare linear, polynomial and lowess fits.
- Heatmaps with sns.heatmap Turn a table of numbers into a colour grid with sns.heatmap: annotations, number formats, colormaps, centering, masks, frames and colorbar control.
- Correlation Heatmaps and Triangle Masks Compute a correlation matrix with pandas, draw it as a seaborn heatmap, hide the redundant half with a mask, and read the result without fooling yourself.
- Clustermaps: Hierarchically Clustered Heatmaps Group similar rows and columns automatically with sns.clustermap: linkage methods, distance metrics, standardizing, color bars and reading dendrograms.
Multi-plot Grids
- FacetGrid: Small Multiples in Seaborn Split a dataset into a grid of subplots with FacetGrid: rows, columns, hue, map and map_dataframe, shared axes, titles, legends and sizing.
- Pair Plots and PairGrid Compare every numeric column against every other with pairplot, then take full control with PairGrid: diagonal plots, triangles, hue, corner and custom functions.
- Joint Plots with Marginal Distributions Combine a scatter plot with marginal histograms or density curves using jointplot and JointGrid: kinds, hue, hexbins, regression and custom margins.
- Ridgeline Plots in Seaborn Build a ridgeline (joy) plot with FacetGrid: stacked, overlapping density curves for many groups, with sorting, colours, labels and common pitfalls.
Styling and Themes
- Axis Labels, Titles, Figure Size and Legends Set titles, axis labels and figure size for axes-level and figure-level seaborn plots, rotate ticks, and move the legend outside the plot area.
- Themes, Styles and Plotting Contexts Control the look of every plot with set_theme: the five styles, the four contexts, font scale, despine, rc overrides and temporary styles with a with block.
- Colour Palettes and Colormaps in Seaborn Choose and build seaborn colour palettes: qualitative, sequential and diverging, color_palette, cubehelix, light_palette, custom colours and colour-blind safe options.
Statistical Estimation
- Error Bars and Confidence Intervals in Seaborn Understand the errorbar parameter in seaborn: confidence intervals, bootstrapping, standard deviation, standard error, percentile intervals and custom functions.
- Time Series Plots and Rolling Averages with Seaborn Plot dates with lineplot, format date axes, resample to weekly or monthly values, add a rolling average and compare periods, with pandas doing the smoothing.
- Estimators and Aggregation: barplot, pointplot and Bubbles Learn how seaborn summarises data with estimators: mean, median, sum and custom functions in barplot and pointplot, plus weighted bubble plots and countplot.
Projects and Practice
- Project: Exploring a Penguin-Style Dataset Walk through a complete exploratory analysis with seaborn: inspect data, plot distributions, compare groups, find relationships and write down what you learned.
- Project: A Sales Dashboard with Seaborn Build a one-page sales dashboard: tidy the data with pandas, then combine a trend line, category bars, a heatmap and a distribution in one seaborn and Matplotlib figure.
- Project: An A/B Test Report with Honest Uncertainty Analyse an A/B test with seaborn: compare conversion and revenue, draw bootstrapped confidence intervals, show the distribution of differences and report a clear result.
- Practice: Exercises, Cheat Sheet and Common Mistakes Test your seaborn skills with graded exercises and solutions, a one-page cheat sheet of functions, and the most common mistakes and how to fix them.