LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 25 lessons

Lesson 5 of 9

Module 3 · Figures that tell the truth

Honest axes and scales

Honest axes and scales

Honest axes and scales

The same numbers can look like a small difference or a huge one, depending on where the axis starts. Readers trust that you chose fairly.

⏱ 11 min readModule 3 · Figures that tell the truthFree
Lesson at a glance6 steps · about 11 min
  1. One pair of numbers, two pictures
  2. What this does, line by line
  3. Reading the output
  4. Rules that keep scales honest
  5. Each rule, explained
  6. What this does

One pair of numbers, two pictures

In a bar chart, readers judge a value by the length of the bar, and they compare bars by the ratio of their lengths. That only works if every bar starts at zero. When the axis starts higher, the bars are cut off at the bottom, and what remains no longer has the same ratio as the numbers. This lesson measures how big that distortion can be, using the mean tooth lengths at the 1 mg dose.

The data are the tooth growth measurements used throughout this module since Choosing the right chart: 60 guinea pigs, 10 in each combination of three doses and two vitamin C sources, with the tg table and the okabe colours set up there. Two words recur in this lesson. A scale is the rule that turns data values into positions, lengths or colours on the page; an axis is the drawn ruler, with ticks and labels, that lets the reader run that rule backwards. Most misleading figures keep the data correct and change the scale.

R
d1 <- tg |> filter(dose == "1") |> group_by(supp) |> summarise(mean = round(mean(len), 2), .groups = "drop")
print(as.data.frame(d1))

bars <- ggplot(d1, aes(supp, mean, fill = supp)) + geom_col(width = 0.6) +
  scale_fill_manual(values = okabe, guide = "none") +
  labs(x = NULL, y = "Mean tooth length (dose 1)") + theme_classic(base_size = 11)
pa <- bars + coord_cartesian(ylim = c(15, 25), expand = FALSE) + ggtitle("Axis starts at 15 (misleading)")
pb <- bars + coord_cartesian(ylim = c(0, 25), expand = FALSE) + ggtitle("Axis starts at 0")
pa + pb

What this does, line by line

  • The first line keeps the 20 animals at dose 1, groups them by source and computes each group's mean length, rounded to two decimal places. The result, d1, has two rows.
  • print(as.data.frame(d1)) prints d1 as a plain data frame. A tibble would round the display to about three significant digits; a data frame shows the stored two decimals.
  • bars is a complete bar chart saved as an object but not yet drawn: one bar per source, coloured with the okabe colours from Choosing the right chart, with no legend and no x-axis title.
  • pa adds coord_cartesian(ylim = c(15, 25), expand = FALSE), which zooms the y-axis to exactly the range 15 to 25, and a title. pb zooms to 0 to 25 instead. Both start from the same bars object, so the only difference between them is the axis range.
  • pa + pb uses patchwork, from Comparisons and uncertainty, to place the two versions side by side.

coord_cartesian() works like a camera zoom: the data are untouched, only the visible window changes. Setting limits with ylim() or scale_y_continuous(limits = ...) behaves differently: it removes anything outside the range before drawing, and since every bar begins at 0, bars would disappear from a chart limited to 15–25. That is why the zoom here uses coord_cartesian().

One detail is easy to miss, and it is why both lines say expand = FALSE. ggplot2 pads every continuous axis by 5% of its range on each side, so that points do not touch the edge, and coord_cartesian() keeps this padding by default. Without expand = FALSE the left chart would actually start at 14.5 rather than 15, and the right one at −1.25, which leaves a gap between the bars and the x-axis. The drawn ratio would then be (22.70 − 14.5) ÷ (16.77 − 14.5) = 8.20 ÷ 2.27 = 3.6 rather than the 4.35 worked out below. With expand = FALSE each axis starts exactly at its stated limit, so the worked example describes the charts as drawn. For an ordinary bar chart that is not zoomed, scale_y_continuous(expand = expansion(mult = c(0, 0.05))) removes the padding at the bottom only, so the bars sit on the axis line and the top keeps a little room.

supp mean 1 Ascorbic acid 16.77 2 Orange juice 22.70

Reading the output

Each row is one vitamin C source, numbered 1 and 2 on the left. At 1 mg a day, animals given ascorbic acid had a mean tooth length of 16.77 and those given orange juice 22.70. These two numbers are all the figure below shows.

The difference between the groups is 22.70 − 16.77 = 5.93 units of tooth length, and in relative terms the orange juice mean is 35% higher. Keep both numbers in mind while you look at the two charts: an honest drawing should leave a reader with roughly that impression, not a larger or a smaller one. Note also what the means leave out. Each is the average of 10 animals, and the figure says nothing about how much those animals varied; Comparisons and uncertainty showed how to add that.

Two bar charts of the same means. With the axis starting at 15, the orange juice bar looks four times taller. With the axis starting at 0, it is about one third taller.
The same two numbers, drawn with two different axes.

Worked example · how much a truncated axis exaggerates

true ratio = 22.70 ÷ 16.77 = 1.35 (35% longer)
drawn from 15: (22.70 − 15) ÷ (16.77 − 15) = 7.70 ÷ 1.77 = 4.35
the left chart makes the difference look about three times larger than it is

Step by step. With the axis at 0, each bar's visible length equals its value, so the lengths compare as 22.70 to 16.77, a ratio of 1.35. With the axis at 15, the bottom 15 units of each bar are hidden. The visible lengths are 22.70 − 15 = 7.70 and 16.77 − 15 = 1.77, and 7.70 ÷ 1.77 = 4.35. Dividing the drawn ratio by the true ratio, 4.35 ÷ 1.35 = 3.2, gives the "about three times" exaggeration.

What the answer means. The closer the axis start is to the smaller value, the worse the distortion: an axis starting at 16.5 would leave the ascorbic acid bar almost invisible and make the ratio look enormous. The numbers did not change at all; only the drawing did.

Edward Tufte formalised this kind of distortion as the lie factor in The Visual Display of Quantitative Information (Graphics Press, 1983; 2nd edition 2001): the size of an effect as drawn divided by its size in the data, where size is the relative change. For the bars here, the data change is (22.70 − 16.77) ÷ 16.77 = 0.35, and the drawn change from 15 is (7.70 − 1.77) ÷ 1.77 = 3.35, a lie factor of about 9.5. Tufte treated values outside about 0.95 to 1.05 as substantial distortion. His measure differs from the ratio comparison in the worked example, so say which one you use.

Rules that keep scales honest

  • Bars start at zero. Points and lines need not, because their position, not their length, carries the value.
  • Use log scales for values spanning orders of magnitude, such as read counts (3 to 31,540 in de_results_example.csv) and fold changes, where ×2 and ×½ should look equally large. Label the axis as log.
  • Keep scales the same across panels that will be compared (fixed scales in facet_wrap, the default).
  • Avoid two y-axes on one plot: the apparent relationship depends entirely on how each axis is scaled. Use two panels instead.

All four rules follow from one question: which visual property does the reader use to judge a value, and does the drawing keep that property in proportion to the data? For a bar it is length, for a point it is position along the axis, and for two series on one plot it is their relative height. A rule is broken whenever the chart changes that property without the data changing.

Each rule, explained

  • Points and lines. A dot at 22.70 means 22.70 wherever the axis starts, so a dot plot of the same two means can zoom in to 15–25 honestly. Readers compare positions, not lengths.
  • Logarithms. An order of magnitude is a factor of 10. On a log scale, equal distances stand for equal ratios: the step from 10 to 100 is as long as the step from 100 to 1,000. On an ordinary (linear) axis running to 31,540, every gene below a few hundred counts would be squashed into a thin strip at the bottom. For fold changes, log2 is the usual base: a doubling is +1, a halving is −1, so increases and decreases of the same size sit at the same distance from 0. Zero itself cannot be shown on a log axis, because the logarithm of 0 is undefined; genes with zero counts need special handling, often by adding a small constant before taking logs.
  • Fixed scales. If one facet runs from 0 to 10 and its neighbour from 0 to 40, two bars of equal height mean values four times apart. facet_wrap() keeps the same axes in every panel unless you change its scales argument, for example to "free_y"; do that only when the panels are not meant to be compared.
  • Two y-axes. With one series on the left axis and another on the right, you can make the two lines cross, run parallel or diverge by stretching either axis. The picture says more about the axis choice than about the data.

Two consequences are worth stating. First, a bar needs a meaningful zero. Tooth lengths, counts and concentrations have one. A log scale has none, so the length of a bar drawn on a log axis depends only on where the axis happens to begin; show values on a log scale as points or lines instead. Second, a value that can be negative, such as a log2 fold change, is usually best drawn on an axis symmetric around 0, for example from −4 to 4, so that changes up and down look equally large.

A common pitfall is to apply the rules mechanically. Starting at zero is right for bars, but forcing a dot plot of adult body temperatures to start at 0 °C would squash all the interesting variation into a thin band at the top. Zero on the Celsius scale does not mean "no temperature", so it is not a natural baseline. Choose the range that lets readers judge the differences that matter, and make it clear where the axis starts.

Honest axes and scales · LSMA free course Counts of 3, 30, 300, 3,000 and 30,000 on a linear axis crowd together at the left. On a log axis the same counts are evenly spaced. On a log2 axis, a halving and a doubling sit at equal distances either side of no change. 1 · COUNTS ON A LINEAR AXIS 010,00020,00030,000 3, 30, 300 and 3,000 all sit at the far left 2 · THE SAME COUNTS ON A LOG AXIS 1101001,00010,000100,000 3303003,00030,000 3 · FOLD CHANGES ON A LOG2 AXIS ×¼×½×1×2×4 −2−1012 halving doubling ratio log2
On a linear axis (1) four of the five counts crowd into the left edge; on a log axis (2) each tenfold step takes the same space. On a log2 axis (3) a halving and a doubling are the same distance from no change. Schematic, not to scale.
R
# log scales
ggplot(tg, aes(x = dose, y = len)) + geom_point() + scale_y_log10()

What this does

This draws every animal's tooth length against dose, then scale_y_log10() changes the y-axis to a base-10 log scale. The values themselves are not changed: the tick labels still show tooth lengths, but they are spaced by ratio rather than by difference. Tooth lengths span only about one order of magnitude, so here the change is mild; on read counts it is dramatic. Whenever you use it, say in the axis title or legend that the scale is logarithmic, because a reader who assumes a linear axis will misjudge every difference.

A related choice is whether to transform the scale or the data. aes(y = log10(len)) also gives a log axis, but the tick labels then show the logged values, such as 1.0 and 1.3, which readers must convert back in their heads. scale_y_log10() keeps the original units on the labels and changes only the spacing, so it is usually the friendlier option. In both cases ggplot2 transforms the values before any statistical layer is computed, so a mean drawn with stat_summary() on a log axis is the mean of the logged values, not the ordinary mean. Say so if you show summaries on a log scale.

Go deeper: log axes when some values are zero

A log axis cannot show 0. With scale_y_log10(), a zero becomes minus infinity and ggplot2 warns that the transformation introduced infinite values. The usual fix in omics is to add a small constant, a pseudocount, before taking logs, as in log2(count + 1).

ggplot2 also offers a pseudo-log axis: scale_y_continuous(transform = "pseudo_log") (ggplot2 3.5 or later; older versions spell the argument trans). It behaves like an ordinary linear axis close to zero and like a log axis for large values, so 0, 5 and 30,000 can share one axis without changing the data. Two cautions. The axis is neither linear nor log in between, so name the transformation in the legend. And a pseudocount changes ratios of small counts a lot: counts of 1 and 4 have a ratio of 4, but (4 + 1) ÷ (1 + 1) = 2.5.

Key point

If you must zoom in on a bar chart, switch to points, or mark the break in the axis clearly. Never let the drawing imply a ratio the data do not support.

A second example: a news chart shows unemployment rising from 5.0% to 5.5%, with the axis starting at 4.8%. The first bar is 0.2 units tall and the second 0.7, so the rise looks more than threefold, when the real change is a tenth (5.5 ÷ 5.0 = 1.1). A line or dot chart with a clearly labelled axis tells the same story without the false drama.

Further reading · Module 3Weissgerber et al. 2015: why bar charts hide the data, with examples. · All reading for this course

Check your understanding

1. Values 50 and 55, bars drawn from 45. How many times taller does the second bar look?

2. Which data most need a log scale?

3. Why avoid two y-axes on one plot?

Up next

Lesson 6

Multi-panel figures

Ask BioTutor

Create a free website with Framer, the website builder loved by startups, designers and agencies.