Foundations of Data Science slides 📂 Introduction · 7 of 10 34 min read

Understanding Box Plots: Read a Whole Distribution at a Glance

One compact chart that shows a dataset's centre, spread, skew, and outliers all at once. This tutorial breaks down box-plot anatomy — the IQR box, median line, whiskers, and outlier dots — how it's built from the five-number summary, how to read skewness from its shape, comparing groups side by side, box plot vs histogram, violin plots, and Python code — with animated diagrams.

📦

Understanding Box Plots

One compact chart that shows a dataset's centre, spread, skew, and outliers all at once — a visual summary of quartiles, IQR, and the five-number summary that makes comparing groups effortless.
Five-Number Summary IQR Box Skew At A Glance Compare Groups

Press Next → or use ← → arrow keys

Section 01

The Intuition — An X-Ray Of Your Data

The whole distribution, in one glance
A doctor doesn't read every pixel of an X-ray — they see the skeleton in one look. A box plot does the same for data: instead of scrolling a thousand rows, you glance at a single little box-and-whisker shape and instantly know where the data sits, how spread out it is, whether it leans one way, and which points are unusual.

It's the chart that turns the five-number summary — minimum, Q1, median, Q3, maximum — into a picture you can read in a second, and line up side by side to compare groups.
💡
Four Answers From One Shape

A box plot answers centre (where's the median?), spread (how wide is the box?), skew (is the median off-centre?), and outliers (any dots past the whiskers?) — all in a single, compact drawing.

Section 02 · Anatomy

Every Part Of A Box Plot

value → IQR (middle 50%) upper fence (Q3 + 1.5·IQR) min Q1 median Q3 max* outlier
🧩
Box, Line, Whiskers, Dots

The box spans Q1 to Q3 (the IQR — middle 50%). The line inside is the median. The whiskers reach to the last points within the fences, and anything past them is drawn as an individual outlier dot. (The whisker end is the min/max inside the fence, not necessarily the overall extreme.)

Section 02 · Foundations

Built From Quartiles & The IQR

🧮 From Sorted Data To A Box (using [4,7,9,12,15,18,21,24,28,35,38,45])
1Sort the data and find the median: Q2 = 19.5.
2Quartiles: Q1 = 10.5, Q3 = 31.5 → the two edges of the box.
3IQR = Q3 − Q1 = 21 → the box width, the spread of the central half.
4Fences at Q1 − 1.5·IQR and Q3 + 1.5·IQR mark where whiskers stop and outliers begin.
5Draw the box, median line, whiskers to the last in-fence values, and dots beyond.
🔗
The Five-Number Summary, Drawn

A box plot is nothing more than the five-number summary — min, Q1, median, Q3, max — rendered as a shape, with the 1.5×IQR rule deciding which extremes get promoted to outlier dots. Master quartiles and IQR, and the box plot reads itself.

Section 03 · Reading It

How To Read A Box Plot In Seconds

🎯
The Median Line
Your one-glance "typical value." Comparing medians across groups tells you which is higher at a glance.
↔️
The Box Width
A wide box = high variability in the middle 50%; a narrow box = consistent, tightly-clustered data.
The Dots
Each dot beyond a whisker is a flagged outlier — worth investigating, never ignoring.
👁️
Density You Can't See — And That's Fine

A box plot deliberately hides how many points sit in each region — it shows position, not density. That abstraction is its superpower: it strips a messy distribution down to the five numbers that matter, so nothing distracts from centre, spread, and outliers.

Section 04 · Skew

Reading Skewness From The Shape

Symmetric median centred · equal whiskers Right-skewed (+) median left · long right whisker/tail Left-skewed (−) median right · long left whisker/tail
🧭
The Median's Position Tells The Story

If the median sits centred with equal whiskers, the data is symmetric. If it's pushed toward the left of the box with a long right whisker, the data is right-skewed (a tail of high values). Pushed right with a long left whisker → left-skewed. The longer whisker always points toward the tail.

Section 05 · Comparing

Where Box Plots Truly Shine — Comparison

score → Team A Team B Team C
⚖️
Read Three Groups In One Look

Team B scores highest but is the most variable (tall box). Team A is lower yet remarkably consistent (short box). Team C sits in the middle with one standout outlier. Stacking box plots side by side makes differences in level, spread, and anomalies jump out instantly — this is what they do better than any other chart.

Section 06 · Box vs Histogram

Two Views Of The Same Data

Histogram · shows density & shape Box plot · shows summary & outliers same distribution, complementary lenses
🔬
Histogram For Shape · Box Plot For Summary

A histogram shows the full shape — how many points sit where, whether it's bimodal, how the tail decays. A box plot compresses that into five numbers plus outliers, so it scales to comparing many groups at once. Use the histogram to understand one distribution, the box plot to compare many.

Section 07 · Variations

Beyond The Basic Box

🎻
Violin Plot
A box plot wrapped in a mirrored density curve — you get the five-number summary and the shape, revealing bimodality a plain box hides.
〰️
Notched Box
A notch around the median shows its confidence interval — if two groups' notches don't overlap, their medians likely differ.
🐝
Box + Strip / Swarm
Overlay the raw points on the box so you also see sample size and density — best for small datasets.
🎻
Reach For A Violin When Shape Matters

A box plot can't reveal a two-peaked distribution — two very different groups can share an identical box. A violin plot shows the density silhouette, so if you suspect hidden sub-groups, it's the safer choice.

Section 08 · Code

Box Plots In Python

import matplotlib.pyplot as plt
import seaborn as sns

# ── matplotlib: quick single box ──
plt.boxplot(scores, vert=True, showmeans=True)

# ── seaborn: compare groups in one line ──
sns.boxplot(data=df, x="team", y="score")      # one box per team
sns.violinplot(data=df, x="team", y="score")   # add the shape

# ── pandas: straight from a DataFrame ──
df.boxplot(column="score", by="team")
🎨
Seaborn Makes Grouped Box Plots Trivial

Point seaborn.boxplot at a categorical x and a numeric y and it draws one box per category automatically — the fastest way to compare distributions across groups. Add hue= to split each group by a second category, or swap in violinplot to layer on the density.

Section 09 · Fit

When To Use — And Its Blind Spot

✅ Reach For A Box Plot When…❌ Be Careful When…
Comparing a numeric variable across groupsThe distribution might be bimodal (box hides it)
You need to spot outliers quicklyThe sample is tiny (few points → misleading quartiles)
Data is skewed and the mean would misleadYour audience doesn't know how to read one
You want centre + spread + skew in one chartYou need exact counts or density (use a histogram)
🕳️
The One Thing A Box Plot Can't Show

It hides how the data is distributed inside the box. Two datasets — one uniform, one with a giant gap in the middle — can produce the identical box plot. When the shape itself matters, pair it with a histogram or a violin plot before you conclude.

Section 10 · Golden Rules

Six Rules For Box Plots

🏅 Box Plots, Distilled
1Read the median first, then the box width, then the whiskers, then the dots — in that order.
2Use them to compare groups. Side-by-side box plots are their killer feature.
3The long whisker points to the tail — that's your instant skewness read.
4Every dot is a lead, not a nuisance. Investigate outliers before removing them.
5Pair with a histogram or violin when the distribution's shape (e.g. bimodality) matters.
6Be cautious with tiny samples — quartiles from a handful of points are unstable.
Wrap-Up

You Can Now Read Any Box Plot

boxQ1 → Q3 (IQR)
lineMedian
whiskerIn-fence range
dotsOutliers
skewLong whisker = tail
compareSide by side
🎯
The Through-Line

A box plot draws the five-number summary as one compact shape — median, IQR box, whiskers, and outlier dots — so you read centre, spread, skew, and anomalies at a glance and line groups up for instant comparison. When the inner shape matters, back it with a histogram or violin plot.

📚
Where To Go Next

Box plots sit on top of quartiles & the IQR — revisit those to cement the fences — then broaden into histograms, violin plots, and scatter plots to round out your data visualization toolkit.

📦 End of tutorial · Press to review, or click Restart