A graph turns numbers into lengths, positions, areas and colours, and the eye then compares those. A good graph makes the comparison that matters easy and true; a misleading one makes the eye compare something that the numbers do not support.
Summary numbers are compressions, and very different data can compress to the same numbers. The classic demonstration is Anscombe’s quartet: four data sets with the same means, the same variances, the same correlation and the same regression line.
Figure 1.4.1: Anscombe’s quartet. All four have mean x = 9, mean y = 7.5, correlation 0.82 and the regression line y = 3 + 0.5x (red). Only the pictures reveal that I is a noisy straight line, II a clean curve, III a straight line with one outlier, and IV no relation at all except through one extreme point.
The same holds for group comparisons. A bar with an error bar on top (a “dynamite plot”) shows two numbers per group and hides everything else:
Code
groups = {"A": rng.normal(10, 3, 40),"B": np.r_[rng.normal(6, 1, 20), rng.normal(14, 1, 20)],"C": np.r_[rng.normal(7, 1.2, 35), rng.normal(31, 4, 5)],}groups = {k: v - v.mean() +10for k, v in groups.items()}fig, axes = style.subplots(2, height=3.2, width=10)means = [v.mean() for v in groups.values()]errors = [v.std(ddof=1) / np.sqrt(len(v)) for v in groups.values()]axes[0].bar(list(groups), means, yerr=errors, color=style.GREY, alpha=0.7, capsize=6)axes[0].set(ylabel="value", title="Bars and error bars", ylim=(0, 40))for i, values inenumerate(groups.values()): axes[1].scatter( i + rng.uniform(-0.15, 0.15, len(values)), values, s=10, color=style.BLUE, alpha=0.7 )axes[1].boxplot(list(groups.values()), positions=range(3), widths=0.5, showfliers=False)axes[1].set_xticks(range(3), list(groups))axes[1].set(ylabel="value", title="The data", ylim=(0, 40))fig.tight_layout()plt.show()
Figure 1.4.2: Three simulated groups with the same mean. Left: as bars with error bars, they look nearly identical. Right: the same data as dots with a box plot. Group A is roughly normal, group B has two clusters, and group C is mostly low with a few very high values. The bars hid all of it.
1.4.2 Bars start at zero
A bar shows a value by its length, so a bar chart whose axis does not start at zero lies: a 4% difference can look like a doubling. A line or dot shows a value by its position, and there the axis may start wherever the data are, because the eye compares positions, not lengths.
Figure 1.4.3: The same two numbers, 50.1 and 52.0. Left: bars on an axis starting at 49.5; B looks four times as large as A. Middle: bars from zero; the difference is small, as it is. Right: dots on a zoomed axis are fine, because position, not length, carries the value; the axis labels say how small the difference is.
1.4.3 Area grows with the square
When a value is shown by the size of a picture, the eye judges its area. A circle or icon drawn twice as wide and twice as high has four times the area. Scaling both dimensions by the value exaggerates differences; scale the area, or better, use lengths.
Figure 1.4.4: Two values, 1 and 2. Left: circles whose diameter follows the value; the larger one has four times the area and looks far more than twice as big. Middle: circles whose area follows the value; correct, but areas are still hard to compare by eye. Right: bars, whose lengths the eye compares best.
This is also why pie charts are hard to read: angles and areas of similar slices are difficult to compare, while the same shares as bars are easy.
Figure 1.4.5: Five shares (23%, 21%, 20%, 19%, 17%) as a pie and as sorted bars. In the pie, ranking the slices is guesswork; in the bars, it is immediate.
1.4.4 Two y-axes can say anything
A chart with two vertical axes lets the maker stretch and shift each axis freely, and with that, make two series appear to move together, diverge, or cross wherever they like. The “relationship” is in the choice of axes, not in the data.
Figure 1.4.6: The same two unrelated simulated series in both panels, each with its own axis. Left: the axes are chosen so that the lines track each other. Right: the second axis is shifted and stretched, and now sales seem to start below rainfall and overtake it. To compare two series honestly, index both to 100 at a common start, or plot one against the other.
1.4.5 Bins and smoothing shape the story
A histogram’s appearance depends on its bin width, and a smoothed curve on its smoothing. Too wide hides structure; too narrow invents it. Try several, and say which was used.
Figure 1.4.7: The same 300 simulated values, which come from two overlapping groups, with three bin widths. Wide bins (left) show one hump; medium bins (middle) show the two; very narrow bins (right) show a ragged landscape of spikes that mean nothing.
1.4.6 Colour
Colour carries three kinds of information, and each needs its own kind of colour scale:
Categories (species, countries): clearly different hues, no order implied.
Ordered values (temperature, density): a sequential scale from light to dark.
Values around a midpoint (gains and losses, correlations): a diverging scale, two hues meeting at a neutral middle.
The once common rainbow scale is a poor choice for ordered values: its brightness rises and falls, so it creates sharp bands where nothing changes and hides real gradients, and it fails for readers with colour vision deficiencies (about 1 in 12 men).
Figure 1.4.8: One smooth surface with a single gentle peak, in three colour scales. Left: the rainbow (‘jet’) scale invents bands, at the bright yellow and cyan, where the surface changes smoothly. Middle: a perceptually uniform sequential scale (‘viridis’) shows the smooth rise as it is. Right: a diverging scale centred on the average, for when above and below the middle is what matters.
1.4.7 A checklist
What is the one comparison the reader should make? Put those things next to each other, on a common scale.
Show the data where possible: points, not just summaries.
Bars start at zero; dots and lines need not.
Show values by length or position, not by area or angle.
Avoid two y-axes; index series to a common start instead.
Say what the error bars are (standard deviation, standard error, 95% interval); they differ a lot.
Label axes with units; keep scales the same across panels that are compared.
Use colour scales that match the data: categorical, sequential or diverging.
1.4.8 In one picture
Different data can share every summary number (Anscombe); look at the data.
Bar-and-error-bar charts hide distributions.
Truncated bars, area scaling, pies and dual axes distort comparisons.
Bins and smoothing change the story; try several.
Match the colour scale to the data; avoid the rainbow for ordered values.