Density Plot
A smooth, continuous curve that estimates the probability distribution of a variable — like a histogram without the bins, revealing the true shape of your data.
// 01 — The chart
What it looks like
A density plot showing API response times. The smooth curve reveals a right-skewed distribution with most requests completing quickly.
// 02 — Definition
What is a density plot?
A density plot (also called a kernel density estimate or KDE plot) displays the distribution of a continuous variable as a smooth curve. Instead of sorting data into bins like a histogram, it places a small “kernel” (usually a bell curve) at every data point and sums them up to produce a continuous estimate of the underlying probability distribution.
The Y-axis shows probability density, not raw counts. This means the area under the entire curve always equals 1. A taller peak means values are more concentrated in that region; a flatter section means they’re spread out.
Density plots solve a key limitation of histograms: they don’t depend on arbitrary bin boundaries. This makes them especially useful when you want to compare the shapes of two or more distributions by overlaying them on the same axes.
Origin: Kernel density estimation was formalized by Murray Rosenblatt (1956) and Emanuel Parzen (1962). The technique grew out of the need for a non-parametric way to estimate probability density functions without assuming the data follows a specific distribution.
// 03 — Anatomy
Parts of a density plot
// 04 — Usage
When to use it — and when not to
- You want to see the shape of a distribution without bin artifacts
- Comparing two or more distributions on the same axis (overlay them)
- You have a large dataset (500+ observations) and want a clean summary
- Looking for multimodality — multiple peaks in the data
- You need to estimate probability density rather than raw counts
- Presenting results where a smooth curve is more visually polished
- You have fewer than 30 observations — KDE will oversmooth noise
- Exact counts matter — density doesn't show counts, only relative likelihood
- Your data has hard boundaries (e.g., 0–100) — KDE bleeds past edges
- The audience is unfamiliar with density — use a histogram instead
- Your data is categorical — density only works for continuous variables
- You need to show exact bin frequencies for regulatory or audit purposes
// 05 — Reading guide
How to read a density plot
Follow these steps whenever you encounter a density plot.
Read the axis labels
The X-axis shows the variable being measured. The Y-axis shows density — it tells you where values are concentrated, not how many there are.
Look at the overall shape
Is the curve symmetric, left-skewed, or right-skewed? Does it have one peak (unimodal), two peaks (bimodal), or more? The shape tells the story.
Find the peak (mode)
The highest point of the curve shows where values are most concentrated. This is the most likely value in your dataset.
Assess the spread
A narrow, tall curve means data is tightly clustered. A wide, flat curve means high variability. Compare the width at half-height for quick spread assessment.
Check the tails
Long tails suggest outliers or extreme values. A tail extending to the right (positive skew) is common in income, response time, and price data.
// 06 — Data format
What your data should look like
A density plot requires a single column of continuous numeric values. For overlaid density plots, add a grouping column.
| value | group |
|---|---|
| 142 | Server A |
| 187 | Server A |
| 203 | Server B |
| 156 | Server A |
| 298 | Server B |
// Python example
import seaborn as sns sns.kdeplot(data=df, x="value", hue="group", fill=True)
// 07 — Construction
How to build a density plot
Collect your raw continuous data — the more observations, the better the estimate
Choose a kernel function (Gaussian is standard) and a bandwidth parameter
Place a kernel at each data point, then sum all kernels to form the density curve
Normalize the curve so the total area under it equals 1
Plot the resulting curve on X (variable) vs Y (density) axes
Optionally shade the area under the curve and add a vertical line for the mode
// 08 — Pitfalls
Common mistakes
Wrong bandwidth
Too narrow creates a noisy, spiky curve. Too wide hides important features. Always experiment with bandwidth.
Ignoring boundary effects
KDE can produce density outside valid ranges (e.g., negative response times). Clip or use boundary-corrected methods.
Overlaying too many groups
More than 3–4 overlapping density curves become unreadable. Use ridgeline plots or facets instead.
Interpreting height as count
The Y-axis is density (probability per unit), not frequency. A peak at 0.02 doesn't mean 2% of data — the area between two X values does.
Too few data points
KDE on small samples (n < 30) creates a misleading smooth curve from essentially random noise.
// 09 — In the wild
Real-world examples
Overlaying the density of daily stock returns for two portfolios to compare risk profiles and tail behavior.
Plotting patient blood pressure readings as a density curve to see whether the sample follows a normal distribution.
Comparing API response time distributions before and after a performance optimization, with two overlaid curves.
// 10 — At a glance
Quick reference
| Also known as | KDE plot, kernel density plot, probability density curve |
| Category | Distribution |
| Data type | One continuous numeric variable (optionally with a grouping column) |
| Axes | X = measurement variable, Y = probability density |
| Minimum data | 30+ observations (ideally 200+) |
| Key parameter | Bandwidth — controls the smoothness of the curve |
| First used | Rosenblatt (1956), Parzen (1962) |
// 11 — Accessibility
Accessibility notes
Use high-contrast colors between overlaid curves — consider dashing or thickness differences
Always fill the area under curves with distinct patterns or semi-transparent fills
Provide a text summary: 'The distribution peaks at 310 ms with a right-skewed tail'
Add aria-labels describing the shape and key statistics (mean, median, spread)
For screen readers, provide a data table with percentile summaries as an alternative
// 12 — Variations
Variations
Overlaid density
Multiple density curves on the same axes for group comparison — use transparency for readability.
Mirrored density
Two densities mirrored vertically — used in half-eye and raincloud plots for compact comparison.
Filled vs. outline
Filled areas emphasize volume; outline-only curves work better when overlaying many groups.
2D density (contour)
Extends KDE to two dimensions, creating a contour map showing where bivariate data concentrates.
// 13 — FAQs
Frequently asked questions
What is a density plot?+
A density plot (also called a kernel density estimate or KDE plot) displays the distribution of a continuous variable as a smooth curve. Instead of sorting data into bins like a histogram, it places a small "kernel" (usually a bell curve) at every data point and sums them up to produce a continuous estimate of the underlying probability distribution.
When should you use a density plot?+
Use a density plot when you want to see the shape of a distribution without bin artifacts. It also works well when comparing two or more distributions on the same axis (overlay them), and when you have a large dataset (500+ observations) and want a clean summary.
When should you avoid a density plot?+
Avoid a density plot when you have fewer than 30 observations — KDE will oversmooth noise. It is also a poor fit when exact counts matter — density doesn't show counts, only relative likelihood, or when your data has hard boundaries (e.g., 0–100) — KDE bleeds past edges.
What data do you need to make a density plot?+
A density plot requires a single column of continuous numeric values. For overlaid density plots, add a grouping column.
Are density plots accessible to screen readers?+
Yes — a density plot can be made accessible to screen readers by pairing it with a clear text summary of the key insight, ensuring color choices meet WCAG contrast guidelines, adding descriptive alt text or aria-label to the SVG, and offering the underlying data as an HTML table fallback for assistive technologies.
Is a density plot suitable for dashboards?+
Yes — a density plot can work well in dashboards as long as the panel is large enough for readers to perceive the encoded values, has a clear title, and includes the legend or axis labels needed to interpret it.