Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

A heatmap is a statistical graphic that uses color to show the size of values in a table or matrix. Each cell represents one number, and the color of the cell tells you whether that number is low, middle, or high. Heatmaps matter because they help people see patterns that are hard to notice in rows of numbers.

They are widely used for correlations, survey results, temperatures, gene expression, website clicks, and many other data sets.

To read a heatmap, match each cell color to the color scale or legend. In a correlation heatmap, values often range from -1 to 1, where colors can show negative, near-zero, and positive relationships. In an intensity heatmap, larger counts or measurements may be shown with warmer or darker colors.

Choosing the right color scale is important because a poor scale can hide patterns or exaggerate differences.

Understanding Statistics: Heatmaps

The meaning of a color depends on the range chosen before the graph is drawn. Suppose test scores run from forty to one hundred. A score of seventy may look like a middle color if the scale uses that full range.

If the scale starts at sixty, the same score can look much lower. This is why the numbers at the ends of the legend matter. Some heatmaps use equal steps between colors.

Others place more color changes near values that are common or important. When comparing two heatmaps, check whether they use the same scale. Similar shades do not prove that the underlying values are similar.

The arrangement of the grid strongly affects what people notice. Rows and columns can be put in alphabetical order, time order, size order, or an order found by a computer method called clustering. Clustering places similar patterns close together.

This can reveal blocks, such as groups of students with similar answer patterns on a survey. It can be useful, but it can hide the original order of the data.

In a heatmap of monthly rainfall, time order is usually more meaningful than clustering. Labels, grouping lines, and a clear title help the reader understand why nearby cells belong together.

Before making a heatmap, data often need cleaning and scaling. Missing measurements should not be given the same color as a true zero unless zero is really the value. A blank, gray cell, or a separate pattern can show missing data.

Variables measured in different units may need standardising before their patterns are compared. For example, income values may be in thousands while satisfaction scores run from one to five. Raw values would make the income differences dominate.

Standardising describes each value by its distance from that variable's usual level. This makes relative patterns easier to compare, though it removes the original units.

Heatmaps are common in school work and everyday technology. A class survey can show which activities different year groups prefer. A timetable can show busy times in a library.

Weather sites use grids to show changing temperature or rainfall across a region. In science, a correlation heatmap can help researchers spot variables that move together. It cannot show that one variable causes the other.

A dark pattern may result from chance, a small sample, or a hidden factor affecting both variables. Students should check the legend, units, ordering, missing values, and sample size before writing a conclusion. A heatmap is a fast way to find places worth investigating, not a replacement for careful evidence.

Key Facts

  • A heatmap encodes a numeric value by cell color in a grid of rows and columns.
  • A color legend maps colors to numbers, such as blue = low, yellow = middle, red = high.
  • For a correlation heatmap, the correlation coefficient satisfies -1 ≤ r ≤ 1.
  • A positive correlation means two variables tend to increase together, while a negative correlation means one tends to increase as the other decreases.
  • For a data matrix X, each heatmap cell can represent x_ij, the value in row i and column j.
  • Use a sequential color scale for ordered values and a diverging color scale for values centered around a meaningful midpoint, such as 0.

Vocabulary

Heatmap
A graph that displays values in a matrix by coloring each cell according to its numerical size.
Color scale
A rule that connects numerical values to specific colors in a visualization.
Correlation matrix
A square table showing the correlation coefficient for every pair of variables in a data set.
Intensity
The magnitude or strength of a value, often shown by a darker, brighter, or warmer color.
Diverging scale
A color scale that uses two different color directions from a central value such as zero.

Common Mistakes to Avoid

  • Ignoring the legend, which is wrong because the same color can mean different numbers in different heatmaps.
  • Treating color differences as exact numerical differences, which is wrong because colors usually show approximate value ranges unless exact labels are provided.
  • Using a rainbow color scale without a clear reason, which is wrong because uneven color changes can make patterns look stronger or weaker than they really are.
  • Assuming correlation means causation, which is wrong because a strong color in a correlation heatmap shows association, not proof that one variable causes another.

Practice Questions

  1. 1 A heatmap legend maps 0 to dark blue, 50 to pale yellow, and 100 to red. If a cell has value 75, should its color be closer to pale yellow or red, and why?
  2. 2 In a correlation heatmap, the correlation between hours studied and test score is r = 0.82, while the correlation between hours studied and hours of sleep is r = -0.30. Which relationship is stronger in magnitude, and what does each sign mean?
  3. 3 A heatmap of classroom quiz scores uses red for high values and blue for low values. Several students have red cells on algebra questions but blue cells on geometry questions. What pattern does this suggest, and what should the teacher be careful not to conclude from the colors alone?