Evidence, Data and Statistics for Readers
How to Read a Heat Map Without Being Fooled by the Color Scale
Decode heat map colors correctly by checking the scale type, its limits, any rescaling and the effect of ordering and area.
Key takeaways
- Read the color bar and its units before looking for patterns, because colors have no fixed meaning.
- The limits of the scale control the contrast, and values beyond them are often squeezed into the end colors.
- Rainbow scales can create sharp boundaries where the data change smoothly, while scales with steadily changing lightness are safer.
- Rescaling each row can reveal relative patterns but erases differences in actual size between rows.
A heat map shows numbers as colors, usually in a grid or across a surface. To read one correctly, find the color bar first and answer three questions: which colors mean high and low, what values sit at the two ends, and whether the numbers were transformed before they were colored.
Your eye is quick at spotting patches of color and poor at turning color back into numbers. Choices about the scale can make the same table look dramatic or flat.
What a heat map is
In the grid form, rows and columns stand for two sets of categories, and each cell's color shows a value. Examples include temperature by month and hour, activity of many genes across samples or visits by day of the week. In the surface form, color varies across a map or image, as with rainfall over a region or heat over a circuit board.
The strength of the design is density. Hundreds of values fit in a small space, and blocks, stripes and gradients stand out. The cost is precision. Telling whether one shade represents 41 or 47 is hard, particularly when the cells are far apart.
Three kinds of color scale
A sequential scale runs in one direction, commonly from light to dark. It suits quantities that go from low to high, such as counts or concentrations.
A diverging scale has two contrasting hues meeting at a neutral middle. It suits values with a meaningful center, such as change above and below zero. Check what the neutral color really stands for. If it is placed at the average of the data and not at zero, small increases may be colored like decreases.
A categorical palette uses distinct colors for unordered classes, such as soil types. Reading "more" or "less" into those colors is a mistake.
The trouble with rainbows
Rainbow scales run through blue, green, yellow and red. They are colorful, and they cause two problems. First, perceived brightness does not rise steadily along them. Yellow looks bright in the middle of the range, so middle values can seem to stand out as peaks.
Second, we see sharp edges where one named color turns into another, while within a broad green band real differences are hard to notice. A smooth slope can look like a series of steps.
Scales designed to be perceptually uniform try to make equal steps in the data look like equal steps in color. The scale called viridis, common in scientific plotting software, is one example. Scales that change steadily in lightness also survive printing in gray.
Color vision matters too. Difficulty telling certain reds from greens is fairly common, especially among men. A red-to-green heat map may be nearly unreadable for some of your audience.
Limits, clipping and bins
The same table can be drawn with a scale from 0 to 100 or from 40 to 60. The narrow scale turns small differences into vivid contrast. The wide one may show almost uniform color. Neither is automatically right, but you must read the numbers at the ends.
Clipping assigns every value beyond a limit the same end color. It keeps one extreme cell from washing out the rest. It also means two cells of the same dark red might hold 60 and 600. Look for symbols such as "≥ 60" on the color bar.
Binning divides values into a few classes, each with one color. It makes lookup easier and creates edges. Values of 49 and 51 can look quite different if a boundary sits at 50, while 51 and 69 look identical. Equal-width bins and bins holding equal numbers of cells can produce very different pictures.
A logarithmic color scale gives equal color steps to equal ratios, which helps with values spanning many orders of magnitude. Zero cannot be placed on it, so check how zeros and missing values are shown.
Rescaling by row
Many heat maps, notably in biology, standardize each row. Each value is replaced by how far it lies above or below that row's mean, in units of the row's standard deviation. This is a z-score.
row 1 values: 2, 4, 6 mean 4, SD 2
z-scores: −1, 0, +1
row 2 values: 200, 400, 600 mean 400, SD 200
z-scores: −1, 0, +1 The two rows get identical colors although one is a hundred times larger. A row whose values barely vary, say 100, 101 and 102, would also get the same colors. Standardizing answers "in which column is this row relatively high?" and cannot answer "how big is it?" or "is the variation large?"
Normalizing by column, by total or against a control sample changes the question again. The caption or color bar label should say what was done.
Order, area and smoothing
In a grid with unordered categories, rows and columns can be arranged any way. Software often clusters them, placing similar ones side by side. This produces satisfying blocks, even from random data to some degree. A block suggests a grouping worth testing, not a proven one.
On geographic maps that color whole regions, large areas dominate the view regardless of how many people live there. Check whether the color shows counts or rates, a distinction covered in counts, rates and percentages. Sparse regions may have unstable values, and a vivid patch can be a hot spot produced by chance.
Smoothed surfaces fill the space between measurement points with estimated colors. If you have ten weather stations, the map's fine detail comes from the method. Look for markers showing where data were actually collected, and remember the cautions about filling gaps between points.
One table, two pictures
Say a school records average noise level, in decibels, in four rooms at three times of day, and all twelve averages fall between 52 and 58.
Colored on a scale from 52 to 58, the quietest cell is the palest possible and the loudest the darkest. The map looks like a building of extremes. Colored on a scale from 30 to 90, a span chosen to cover quiet and very loud rooms, all twelve cells look nearly the same medium shade.
Which is right depends on the question. To find which room is relatively loudest, the narrow scale helps. To judge whether any room has an unusual noise level, the wide one gives context. A third option is a diverging scale centered on a target value, so that color shows which rooms exceed it.
Whatever the choice, printing the number in each cell costs little in a table of twelve and removes the guesswork. For large grids, a line plot of a few selected rows shows actual values far better than shades can.
Blanks, zeros and gaps
A white cell may mean zero, a very low value, no measurement, a value withheld for privacy or a failed instrument. These are very different. A careful figure gives missing data a distinct look, such as gray or hatching, and says so in the key.
Watch for software that fills gaps with an average or an estimate. The grid then looks complete although some cells were never observed. A pale column in an activity calendar might be a quiet month or a month when the recorder was switched off.
Cells can also differ in how much data stand behind them. An average of 400 readings and an average of 2 readings receive equally solid color. If counts vary widely, look for them in a companion panel or table, and give the thin cells less weight.
Comparing two maps
Side-by-side panels invite comparison, which is fair only if they share a color scale. Software that scales each panel to its own minimum and maximum can make a weak signal in one look as strong as a powerful one in another. Compare the color bars before comparing the pictures.
Neighboring colors also affect perception. The same gray looks lighter on a dark background than on a light one. For an important cell, find the number in a table if you can.
A reading checklist
- What is in each row, column or location?
- What quantity does color represent, in what units?
- Is the scale sequential, diverging or categorical, and where is its middle?
- What are the limits, and are values clipped or binned?
- Were rows, columns or panels rescaled separately?
- How are missing data shown?
- Who chose the ordering or smoothing?
The routine fits within the larger habit of reading a figure before the text. After working through it, state the pattern in words with a number or two. If you cannot attach any numbers to the contrast you see, you do not yet know how large it is.