Foundations to Frontier
Tests
O. Research Skills › O3 Communicating Research

Figures and Visualization for Papers

Readers often look at a paper's figures before its text, so a figure must be honest and readable at a glance, for every reader and in every medium. Colour is the most misused channel: rainbow colormaps such as jet vary in lightness up and down, invent edges, and fail the roughly one man in twelve with red-green colour-vision deficiency. The exercises convert colours to CIELAB to measure each colormap's lightness, then simulate readers who read values back from colour through a legend, with normal vision and with deuteranopia: jet reads accurately with a legend, but its lightness barely follows the value (rank correlation 0.25), and a full-hue rainbow's error nearly triples for deuteranopes, while viridis and gray order values by lightness. Practice problems cover categorical palettes, grayscale printing, truncated axes and Tufte's lie factor, banking slopes to 45 degrees, and overplotting.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A figure is read in seconds

A reviewer flips through the figures before reading a word. In those seconds a figure should show its point without misleading: an axis that starts at zero when bar lengths are compared, colours whose lightness follows the data, labels large enough to read in print, and a design that still works in grayscale and for colour-blind readers.

🎮 Research lab
jet
error 0.011L* rank +0.25
rainbow
error 0.020L* rank -0.51
gray
error 0.023L* rank +1.00
viridis
error 0.018L* rank +1.00

Error: mean absolute error when 2,000 values are read back from the colour with a legend (seed 0). Jet reads well with a legend in colour, but its lightness rises and falls, so in grayscale it becomes ambiguous; rainbow also fails readers with deuteranopia.

Why engineers care

In Exercise 2, a full-hue rainbow colormap read back with a mean error of 0.020 of the range with normal vision and 0.058 with deuteranopia; printed in grayscale (Practice 2), jet’s error rose to 0.195 against 0.031 for viridis.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A good colormap for ordered data has lightness that…
  2. 2. Red-green colour-vision deficiency affects roughly…
  3. 3. Bars compared by length should start at…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Perceptual colour space: CIELAB approximates perception; L* is lightness (0 black, 100 white), and distances such as CIE94 approximate how different two colours look.
  • Sequential colormaps (viridis, cividis, gray) for ordered data: lightness rises monotonically. Diverging maps (two hues around a neutral midpoint) for data with a meaningful centre. Categorical palettes (Okabe-Ito) for labels, with no implied order.
  • Rainbow maps (jet, HSV hue sweeps) are not monotonic in lightness: they create false edges at yellow and cyan and break in grayscale.
  • Colour-vision deficiency: deuteranopia and protanopia merge reds and greens; check figures with a simulator.
  • Honest axes: bars start at zero; a truncated axis multiplies apparent differences (Tufte’s lie factor = effect shown / effect in data).
  • Readable geometry: aspect ratios that put slopes near 45 degrees (Cleveland’s banking), transparency or density plots for many points, direct labels instead of legends where possible.
📝 Quick check (Level 1)
0/3 answered
  1. 1. L* in CIELAB measures…
  2. 2. A diverging colormap suits data that…
  3. 3. Tufte's lie factor compares…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Measuring colormaps and simulated readers

Exercise 1.

  • Convert sRGB colours to linear RGB, XYZ and CIELAB.
  • Build four colormaps: jet, a full-hue rainbow, gray and viridis (a polynomial fit to matplotlib’s).
  • Measure the range of L*, the number of times L* changes direction, and how evenly colour changes along the map.

Practice.

  • Use viridis, cividis or gray for ordered data; a diverging map only when the data have a centre.
  • Check every figure in grayscale and through a colour-vision simulator.
  • Start bars at zero; use points or lines when the baseline is not meaningful.
  • Choose the aspect ratio so the important slopes sit near 45 degrees.
  • Make text in figures as large as the caption, and export vector graphics (PDF or SVG).
legend = seen_lab(colormap(name, linspace(0, 1, 256)), deutan)
x = perceive(seen_lab(colormap(name, v), deutan), rng, sigma=3)
decoded = linspace(0, 1, 256)[argmin(de94_sq(x, legend), axis=1)]
error = abs(decoded - v).mean()
🐍 Exercise 1: colormaps in CIELAB
Convert colormaps to CIELAB and measure their lightness range, lightness reversals and evenness.
📝 Quick check (Level 2)
0/3 answered
  1. 1. How many times does jet's lightness change direction?
  2. 2. Under deuteranopia, the six-colour tab10 palette's closest pair of colours differed by…
  3. 3. The median lie factor of bar charts with an automatically truncated axis in Practice 3 was about…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

From sRGB to lightness. An sRGB value c is first linearised (c/12.92 for small c, ((c + 0.055)/1.055)^2.4 otherwise), mixed into the luminance Y = 0.2126R + 0.7152G + 0.0722B, and compressed: L* = 116 Y^(1/3) − 16 (with a linear piece near black). Mid-gray, c = 0.5, has Y = 0.214 and L* = 53.4: equal steps of sRGB value are close to equal steps of lightness, by design.

Lightness orders values. Readers judge “more” and “less” mostly from lightness. A map whose L* is monotonic preserves order without a legend and survives grayscale; a map whose L* rises and falls, like jet, sends two different values to the same lightness.

Banking to 45 degrees. A segment with slope s at aspect ratio α is drawn at angle θ = arctan(αs). An error δ in the judged angle gives a relative error in the slope of δ/(sin θ cos θ) = 2δ/sin 2θ, smallest at θ = 45 degrees: 7.0% per segment for δ = 2 degrees, twice that at 15 degrees.

The lie factor of a truncated axis. Bars from a baseline z show the relative difference (b − a)/(a − z) between values a and b, while the data’s is (b − a)/a. The lie factor is a/(a − z): an axis starting two points below an accuracy of 88% exaggerates 44-fold.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The L* of mid-gray (sRGB 0.5) is about…
  2. 2. The relative slope error from an angle error δ is smallest at…
  3. 3. The lie factor of bars of value a drawn from baseline z is…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How accurately can readers recover values from jet, a full-hue rainbow, gray and viridis, with normal colour vision and with deuteranopia, and how well does each map’s lightness order the values?

History.

  • W. Playfair (1786) introduced line and bar charts; W. Cleveland and R. McGill (1984) ranked graphical encodings by how accurately people read them, with position first and colour last; Cleveland, M. McGill and R. McGill (1988) proposed banking to 45 degrees.
  • E. Tufte (1983), in The Visual Display of Quantitative Information, defined the lie factor and argued for maximising the share of ink that shows data.
  • D. Borland and R. Taylor (2007) argued that the rainbow colormap is harmful; MATLAB replaced jet as its default with parula in 2014, and matplotlib replaced it with viridis (N. Smith and S. van der Walt) in version 2.0 in 2017.
  • M. Okabe and K. Ito (2002) proposed a palette distinguishable with common colour-vision deficiencies; F. Viénot, H. Brettel and J. Mollon (1999) gave the simulation used here; F. Crameri, G. Shephard and P. Heron (2020) documented the misuse of colour in published science.

Exercise 2.

  • 2,000 values uniform on 0 to 1; each is shown in a colormap’s colour, perceived with noise of 3 CIE94 units along lightness, chroma and hue, and matched to the closest of 256 legend colours.
  • Readers with deuteranopia see plot and legend through the Viénot-Brettel-Mollon simulation.
  • Also the rank correlation between values and their lightness L*.

Seed 0:

colormap mean error, normal vision mean error, deuteranopia worst tenth of range, deuteranopia rank correlation of value with L*
jet 0.0113 0.0167 0.0403 +0.25
rainbow 0.0201 0.0582 0.1277 −0.51
gray 0.0233 0.0242 0.0279 +1.00
viridis 0.0184 0.0237 0.0321 +1.00

Seeds 1 and 2: rainbow 0.0199 and 0.0195 with normal vision, 0.0585 and 0.0607 with deuteranopia; jet 0.0114 and 0.0116, then 0.0168 and 0.0172; viridis 0.0187 and 0.0180, then 0.0238 and 0.0243; lightness correlation of jet 0.24 and 0.26, of rainbow −0.53 and −0.51.

Findings.

  • With a legend, jet was read most accurately in colour: its path through colour space is long, so neighbouring values look different. Its problem is elsewhere.
  • Jet’s and the rainbow’s lightness did not follow the value (rank correlations about 0.25 and −0.5): a reader judging high and low by lightness, or anyone reading a grayscale print, is misled.
  • The full-hue rainbow’s error about tripled with deuteranopia, to about 0.06 of the range on average and 0.13 to 0.15 in its worst tenth.
  • Viridis and gray kept a perfect lightness order and changed least with deuteranopia; gray was unaffected.
🐍 Exercise 2 (research): how accurately can readers recover values from jet, a full-hue rainbow, gray and viridis, with normal colour vision and with deuteranopia, and how well does each map's lightness order the values?
Simulate readers decoding values from four colormaps with normal vision and with deuteranopia, and measure how well each map's lightness orders the values.

Figures in practice

  • Plan figures first: each should make one point, stated in its caption’s first sentence.
  • Use perceptually uniform maps (viridis, cividis, magma; diverging maps such as coolwarm for signed data), and categorical palettes such as Okabe-Ito for groups.
  • Test every figure in grayscale and with a colour-vision simulator before submission.
  • Plot uncertainty: error bars or bands with a stated meaning (topic O2-5), and individual points when there are few.
  • Generate figures from scripts that read the results files, at the final size, with fonts matching the paper; export vector formats.

References

  1. W. S. Cleveland and R. McGill (1984). “Graphical perception: theory, experimentation, and application to the development of graphical methods.” Journal of the American Statistical Association.
  2. E. R. Tufte (1983). The Visual Display of Quantitative Information. Graphics Press.
  3. D. Borland and R. M. Taylor (2007). “Rainbow color map (still) considered harmful.” IEEE Computer Graphics and Applications.
  4. F. Viénot, H. Brettel and J. D. Mollon (1999). “Digital video colourmaps for checking the legibility of displays by dichromats.” Color Research and Application.
  5. F. Crameri, G. E. Shephard and P. J. Heron (2020). “The misuse of colour in science communication.” Nature Communications.