Part II · Advanced topics · Chapter 5

Distribution plots

An average tells you where a variable sits. A distribution tells you what it is doing — whether the values cluster, spread, split in two, or hide a long tail. Graphica can overlay four summaries on a chart you have already built, and bin values directly on an axis.

The overlay

Distribution plot, a section of the chart settings, adds a summary layer over your existing marks. It does not replace them: you keep the individual points and gain a description of them.

OptionWhat it drawsAnswers
NoneThe default.—
Density mapA heat map of where marks are concentrated, through a five-stop colour gradient you control.Where is the mass, once there are too many marks to see it?
Box plotMedian, quartiles and whiskers per group.How do these groups compare in centre and spread?
ViolinThe shape of each group's values, smoothed: wide where they crowd, narrow where they thin out.How is each group spread, and does any of them split in two?
Convex hullAn outline around each group of marks, sharp or smoothed.Where does each group sit, and do they overlap?

All four share an opacity and Distribution plot in front — whether the overlay is drawn over the marks or behind them. Behind is normally the right answer, since the marks are the data and the overlay is the description of it.

Density maps

A scatter plot of fifty thousand points is a solid blob: overplotting hides exactly the structure you loaded the data to find. A density map replaces the guesswork with a gradient, so the concentrations become visible even where every pixel is covered.

The five colours of the gradient are set individually under Heat map colors, from lowest density to highest. The default runs pale to saturated, which is the right direction — the eye reads intensity as quantity, and reversing it produces a map that fights its own reader.

Lowering the opacity of the underlying marks and letting the density map carry the structure is usually better than either alone: the individual points remain visible for outliers, and the shape comes from the overlay.

Plain scatter

About 8,700 earthquakes plotted by longitude and latitude as solid dots: the plate boundaries show as lines, but the busiest stretches, around Japan and Indonesia, merge into solid dark bands where individual quakes cannot be told apart.

Density map behind low-opacity marks

The same points drawn nearly transparent over a density map: warm colors mark where quakes concentrate, showing that the western Pacific and a few spots in the Americas hold far more of them than the rest of each boundary.
Figure 1 — Overplotting, and the same data with a density overlay.

Box plots

A box plot compresses a group into five numbers — median, two quartiles, two whiskers — which makes it the efficient way to compare many groups at once. Twenty categories side by side is unreadable as twenty histograms and perfectly readable as twenty boxes.

The settings cover the Style of the box (three icons: filled, hollow, or a plain box), a default colour, Max width, and Use the same color as marks, which makes each box take the colour of the marks it summarizes — so a chart already coloured by category keeps one colour scheme rather than acquiring a second.

Keep the marks visible

A box plot drawn over the individual points is strictly better than one drawn instead of them. The box gives the summary; the points reveal what the summary destroys — bimodality, gaps, a group of four observations pretending to be a distribution.

This is why the overlay is designed as an overlay. Set the marks to low opacity and leave them in.

Violins

A violin keeps what the box throws away. Instead of five numbers it draws the shape of each group's values along the axis — a smoothed curve, wide where the values crowd and narrow where they thin out, mirrored on both sides of the category. Two peaks, a gap, a long tail: the features a box plot cannot show are the ones a violin makes obvious.

It sits where a box plot would, one per category, and takes the same Max width, default colour and Use the same color as marks. The Style icons choose a full violin or a half violin, which grows from the centre of the category to one side only — to the right when the values run up the chart, upwards when they run across it.

Two things to know when reading one. Every violin is drawn at Max width at its densest point, so its width compares regions within a group, not the size of one group with another: a category of ten values and one of ten thousand look equally wide. And the curve is an estimate: it stops at the smallest and largest value, but between them a handful of points is enough to draw a smooth, confident shape the data cannot support. With few values per group, a box plot over the marks is the more honest choice.

Box plot

Life expectancy by continent, one row per continent, with each country as a translucent dot and a box plot over the dots. Australia's box spans roughly 65 to 73 years, with its whisker running out to two dots near 82.

Violin

The same countries with a violin in place of each box. Australia's violin is widest in the mid 60s and thins to a narrow band that runs out to 82. Asia's trails off in a thin tail down to 54, and Europe's bulges in the low 80s.
Figure 2 — The same groups summarized twice. The box gives centre and spread; the violin shows the shape the box averages away.

Convex hulls

A hull draws an outline around each group of marks. It is the lightest of the four overlays: no statistics, no assumptions, just the boundary of where a group's points fall.

Its value is showing separation and overlap. Two clusters with disjoint hulls are genuinely distinct in the space you are plotting; two whose hulls overlap heavily are not, whatever the colours suggest. That makes hulls a natural companion to clustering — an immediate visual check on whether the groups an algorithm proposed actually separate.

The Style icons choose between sharp, following the outermost points exactly, and smooth, which reads more calmly but implies a boundary slightly larger than the data; a hull also has its own fill opacity and, when sharp, a border width. Note that a hull is defined entirely by its extreme points: one outlier stretches it across the chart, and the fault is the hull's, not the data's.

Iris flowers by sepal length and width, colored by species, each species wrapped in a translucent convex hull: Iris Setosa's hull stands apart at the upper left, while the Versicolor and Virginica hulls overlap across the middle.
Figure 3 — Hulls make separation and overlap explicit.

Histograms

The overlays describe a distribution on a chart of something else. A histogram is the chart: the values of one variable, binned, with each bar counting the rows that fall in its bin.

The wizard builds one for you, and the setting that matters afterwards is Bin width on the axis. It is worth changing deliberately, because bin width decides what the histogram appears to say: wide bins smooth structure away, narrow bins turn sampling noise into peaks. A distribution that looks bimodal at one width and flat at another is a result about the binning, not about the data — so try two or three before believing any of them.

A category before the counts on the same axis gives one histogram per category, all with the same bins. Their counts share one scale unless you tick Independent scales on the count axis — see Encoding.

Choosing among them

You want to knowUse
The shape of one variableHistogram, or a density plot
How several groups compareBox plot
The shape of each group, side by sideViolin
Where the mass is in a crowded scatterDensity map
Whether groups separate in two dimensionsConvex hull
Whether individual values matterKeep the marks, whatever else you add

Where to go next

Part-to-whole and hierarchies is the last chapter — the charts built from proportions rather than positions.