Distribution charts answer where observations lie, how widely they vary, and whether groups differ in shape or rank. The right encoding depends on whether the reader needs familiar bins, compact summaries, cumulative probability, or the detailed shape of each group.
| Reader question | Start with |
|---|---|
| How often do values fall within fixed ranges? | Histogram |
| How do center, spread, and outliers compare across groups? | Boxplot |
| What proportion of observations is at or below each value? | Empirical cumulative distribution |
| How do several binned profiles compare in limited space? | Ridgeline |
| How do several mirrored distribution profiles compare? | Violin |
| Must every observation remain visible? | A beeswarm or strip layout |
Binning, standalone quantiles, and density estimation are data preparation. boxX and boxY own their complete Tukey summaries because independently prepared quartiles, fences, whiskers, and outliers can drift. Dot collision placement belongs to the chart because it depends on final scales, plot bounds, and pixel radii.
Use a dodge layout when every observation should remain visible without moving its measured coordinate.
dot(rows, {
x: 'economy (mpg)',
key: 'id',
r: 4,
layout: dodgeY({ anchor: 'middle', padding: 1 }),
})The Dodge Layouts reference covers anchors, variable radii, identity, and facets.
A histogram groups quantitative observations into intervals. Keep thresholds stable when comparing revisions or groups; otherwise a changed binning decision can look like a changed distribution.
The prepared rows should carry each bin's lower bound, upper bound, and count or proportion. Render those intervals with Bar and Rect Marks. The Scales explains how the application chooses thresholds and reductions.
A boxplot summarizes quartiles, a median, whiskers, and optional outliers. It is compact and comparable, but it does not reveal modes, gaps, or sample size on its own.
Pass the raw observations to boxY, or use boxX for horizontal boxes:
boxY(morley, {
x: 'Expt',
y: 'Speed',
key: 'Run',
fill: '#bfdbfe',
stroke: '#2563eb',
})The mark owns quartiles, 1.5-IQR Tukey fences, observed whiskers, outlier partitioning, and direct source lineage. Its tooltip datum discriminates kind: 'summary' from kind: 'outlier'. The Box Marks reference documents the exact statistics, styling, and interaction targets.
An empirical cumulative distribution shows the proportion of observations at or below each observed value. It avoids bin-width decisions and supports direct percentile comparisons.
Use a step curve because the empirical proportion changes at observations, not continuously between them. State whether ties share a rank and format the vertical axis as a proportion.
Use a ridgeline when several prepared profiles need a shared quantitative axis and compact categorical baselines.
const profiles = normalize(
binX(episodes, {
value: 'imdb_rating',
by: 'season',
thresholds: ratingBoundaries,
outputs: { count: { reduce: 'count' } },
}),
{
value: 'count',
by: 'season',
basis: 'max',
as: 'height',
},
)
ridgelineY(profiles, {
x: 'x',
y: 'season',
height: 'height',
overlap: 0.78,
color: 'season',
})binX retains the episodes in each bin, normalize retains each bin as its immediate source, and ridgelineY owns only the responsive category-step offset. This example is a normalized histogram profile, not a kernel density estimate. The Ridgeline Marks reference documents overlap, category scales, curves, and interaction.
A violin mirrors a prepared normalized profile around each category. It can show modes and shape that a boxplot hides. Its interpretation still depends on the authored bins or density estimator.
const profiles = normalize(
binY(observations, {
value: 'body_mass_g',
by: 'species',
thresholds: massBoundaries,
outputs: { count: { reduce: 'count' } },
}),
{
value: 'count',
by: 'species',
basis: 'max',
as: 'width',
},
)
const summaries = groupBy(observations, {
by: 'species',
outputs: {
median: { value: 'body_mass_g', reduce: median },
},
})
violinY(profiles, {
x: 'species',
y: 'y',
width: 'width',
span: 0.76,
color: 'species',
curve: d3AreaXCurve(curveBasis),
})
tickY(summaries, { x: 'species', y: 'median', span: 0.36 })
dot(summaries, { x: 'species', y: 'median' })violinY owns only mirrored category-step geometry. binY, max normalization, and the median stay visible and retain source lineage. This catalog example is a smoothed normalized histogram, not a kernel density estimate. The Violin Marks reference documents category scales, spans, curves, and interaction.
Area channel details are in Line and Area Marks.