Density, Ridgeline & ECDF Plots: Smooth and Cumulative Views

Histograms and box plots both summarize a distribution, but each throws something away. Density and cumulative plots fill the gaps — one gives you a smooth, bin-free contour you control by hand, the other lets you read any percentile straight off a curve.

A histogram's shape depends on where you put the bin edges; nudge them and the picture wobbles. The kernel density estimate (KDE) solves that by replacing bars with a single smooth curve. We'll use it here on a manufacturing dataset — wafer thickness measurements grouped by recipe — where a clean view of shape, and the ability to compare recipes, matters.

A kernel density estimate of wafer thickness, one smooth curve per recipe
One smooth density curve per recipe — bin-free, and easy to overlay.

What a kernel density estimate actually does

The idea is gentler than the name. For every data point, the KDE drops a tiny smooth bump — a "kernel" — centered on that value. Add all the bumps together and you get a curve that's tall where points crowd together and low where they're sparse. It's a histogram with the jagged edges smoothed away, and unlike a histogram it doesn't depend on arbitrary bin boundaries. Because density curves are translucent and bin-free, you can overlay several recipes on one axis and compare their shapes directly.

Bandwidth: the one knob that matters

A KDE has a single critical setting: the bandwidth, which controls how wide each bump is. It's the smoothing knob, and it's a real trade-off. Too narrow and the curve turns spiky, inventing peaks out of random noise. Too wide and it washes everything into one bland hump, hiding real structure. Stratum exposes the bandwidth directly so you can feel the trade-off live.

The same density curve at different bandwidth settings, from spiky to over-smoothed
Bandwidth controls smoothing: too small is spiky, too large washes out the shape.
You don't have to guess. Stratum can pick a bandwidth for you with established rules — Silverman's and Scott's rules of thumb, or the more adaptive Sheather–Jones method. Silverman and Scott are fast and fine for roughly bell-shaped data; Sheather–Jones works harder and tends to do better on tricky, multi-peaked distributions. Start with an automatic rule, then nudge by hand only if the curve looks too busy or too bland.

Many groups at once: the ridgeline plot

Overlaying three or four densities is fine; overlaying ten is a tangle. The ridgeline plot solves the crowding by giving each group its own row, stacking the density curves vertically with a slight overlap — like a mountain range receding into the distance. It's the most compact honest way to compare the full shapes of many groups, and patterns like a steady upward drift across tools or shifts jump right out.

A ridgeline plot with one density curve per group stacked vertically
Ridgelines stack one density per group — a compact way to compare many distributions.

The ECDF: read any percentile off the curve

Density plots are about shape. When you need exact quantities — medians, percentiles, "what fraction is below the spec limit?" — reach for the empirical cumulative distribution function, or ECDF. It's a rising staircase: at any value x on the horizontal axis, the curve's height tells you the proportion of the data that is less than or equal to x. It starts at 0, climbs to 1, and uses no bins and no smoothing at all — it's the raw data, plotted faithfully.

An empirical CDF curve rising from zero to one
The ECDF: height at any x is the fraction of values at or below x.

This makes percentiles a matter of reading the graph. To find the median, slide across from 0.5 on the vertical axis until you hit the curve, then drop down to the value. Want the 90th percentile? Cross from 0.9 instead. Going the other way is just as easy: pick a spec limit on the horizontal axis, read up to the curve, and you have the fraction of units that meet it — no binning, no interpolation guesswork.

Reading a percentile off the empirical CDF by tracing from the vertical axis
Read percentiles directly: cross from a height to the curve, drop to the value.

The ECDF is also the cleanest way to compare two groups. Plot both staircases together: if one sits consistently to the right of the other, that group simply has larger values across the board — a shift you can see without any test at all. (It's also the visual heart of the Kolmogorov–Smirnov test we'll meet next lesson.)

Finishing touches

To keep the smoothed curve honest, add a rug — little tick marks along the axis showing where the actual observations fall — and overlay the mean and median so the summary statistics sit right on top of the shape they describe.

A density plot with a rug of individual observations and mean and median lines overlaid
A rug shows the raw observations; mean and median lines anchor the curve.

Follow along

Dataset
process_measurements.csv
You'll use
The Density chart with bandwidth control, the Ridgeline variant, the ECDF chart, and a rug with mean/median overlays — thickness and conductivity grouped by recipe or tool
Up next
Lesson 8 — Q-Q Plots & Normality

Density and cumulative plots tell you the shape of your data and where its percentiles fall. But a recurring question lurks underneath: is this distribution normal enough for the tests you're about to run? The Q-Q plot answers that directly — next.