Module 26
Seaborn
Explore tidy data with Seaborn's relational, distribution, categorical, matrix, and regression charts, then theme and finish them.
01
What Is Seaborn
Meet Seaborn, the statistical plotting library built on Matplotlib: import it as sns, hand it a DataFrame and column names, and get a labelled chart.
02
Tidy Data for Seaborn
See why Seaborn wants long-form data, one row per observation and one column per variable, and reshape wide tables with pandas melt before you plot.
03
Scatter Plots with hue, size, and style
Draw relationships with sns.scatterplot and map more columns onto colour, marker size, and marker shape with hue, size, and style, legend included.
04
Line Plots and Error Bands
Use sns.lineplot to draw trends, let Seaborn average repeated x values for you, and read or change the shaded band with errorbar, estimator, and hue.
05
relplot and Small Multiples
Split one chart into a grid of small multiples with sns.relplot, using col, row, and col_wrap, and learn how figure-level functions differ from axes-level ones.
06
Histograms with histplot
Show how one column is spread with sns.histplot: choose bins or binwidth, switch stat to percent or density, and compare groups with hue and multiple.
07
KDE and ECDF Plots
Draw smooth density curves with sns.kdeplot, tune them with bw_adjust, compare groups, and use ecdfplot to read percentiles straight off a curve.
08
Count Plots and Bar Plots
Count rows per category with sns.countplot, compare group means with sns.barplot, and read what the thin error bar on each bar tells you.
09
Box Plots
Summarise a distribution in five numbers with sns.boxplot: read the box, median, whiskers, and outlier dots, and compare several groups side by side.
10
Violin Plots
Combine a box plot with a density curve in sns.violinplot, split each violin by a second group, and choose what is drawn inside with the inner argument.
11
Strip, Swarm, and catplot
Show every observation with sns.stripplot and sns.swarmplot, layer the dots over a box plot, and switch any categorical chart with sns.catplot.
12
Heatmaps
Turn a grid of numbers into colour with sns.heatmap: pivot long data into rows and columns, write values with annot and fmt, and choose a fitting colour map.
13
Regression Plots
Fit and draw a trend line with sns.regplot and sns.lmplot, read the confidence band, try a curved fit with order, and check the leftovers with residplot.
14
Pair Plots and Joint Plots
Scan every pair of numeric columns at once with sns.pairplot, then zoom in on one pair with sns.jointplot and its histograms along both edges.
15
Themes, Contexts, and Palettes
Change the whole look of your charts with sns.set_theme styles and contexts, and choose qualitative, sequential, or diverging colour palettes that fit the data.
16
Customising and Saving Seaborn Charts
Finish Seaborn charts with Matplotlib: draw into subplots with ax=, set titles and limits with ax.set, move the legend, and save figure-level grids.