Heatmap: find patterns in a table of values by color
A heatmap shows a table of numbers as a grid of colored cells: rows for one category, columns for another, and a color for each value. Darker or more intense cells stand for larger values, so the eye finds the hot spots, the stripes and the blocks in seconds, even in a table too large to read cell by cell. It works for any two-way table: defect rate by machine and hour, downtime by line and week, or the correlations between many variables.
When to use it
- You have a value for every combination of two categories, such as press and weekday, and want to see where it is high.
- The table is too big to scan as numbers: 10 machines × 24 hours is 240 cells.
- You look for structure: a whole row (one machine), a whole column (one time slot), or a single cell standing out.
- You want a compact overview to decide where to dig, before a multi-vari chart or a formal test.
How it works
- Arrange the data as a table: one row per level of the first category, one column per level of the second, one value per cell (a count, a rate, a mean).
- Map each value to a color through a color scale, and fill each cell.
- Add a color legend with values, and print the numbers in the cells when there is room.
Three choices shape what the reader sees:
- Color scale. A sequential scale, from light to dark in one hue, suits values that run from low to high, such as rates. A diverging scale, with two hues meeting at a neutral middle, suits values with a meaningful center, such as deviations from target or correlations around zero. Rainbow scales have no natural order and create false boundaries; avoid them. Check that the scale also reads for people with color-vision deficiency.
- Range of the scale. One extreme cell can push every other cell into the same pale color. Consider capping the scale, or showing a second map without the outlier.
- Order of rows and columns. Keep natural orders (hours, days, positions). For categories without one, sorting by row and column averages, or clustering similar rows together, makes blocks visible.
Example
A plant tracks rejects per 1,000 parts at four stamping presses. To look for patterns by day, the engineer averages eight weeks of data by press and weekday:
| Press | Mon | Tue | Wed | Thu | Fri | Sat | Mean |
|---|---|---|---|---|---|---|---|
| P1 | 4.2 | 3.1 | 2.8 | 2.6 | 2.3 | 3.0 | 3.00 |
| P2 | 3.9 | 3.1 | 3.3 | 3.4 | 3.0 | 4.9 | 3.60 |
| P3 | 8.4 | 3.5 | 3.0 | 2.6 | 3.3 | 2.8 | 3.93 |
| P4 | 4.2 | 3.2 | 3.6 | 3.6 | 2.9 | 3.0 | 3.42 |
| Mean | 5.18 | 3.22 | 3.18 | 3.05 | 2.88 | 3.42 | 3.49 |
Drawn as a heatmap with a sequential scale from 2 to 9, three features appear at once:
- One very dark cell: P3 on Monday, at 8.4 rejects per thousand, more than twice the plant average of 3.49.
- A darker Monday column. Every press is worse on Monday: 4.2, 3.9 and 4.2 for P1, P2 and P4, against their Tuesday-to-Saturday averages of 2.76, 3.54 and 3.26. That points to restarting after the weekend shutdown, such as cold dies or dry lubrication.
- One mid-dark cell on Saturday: P2 at 4.9, which suggests something specific to P2's weekend crew or end-of-week tool condition.
The row means alone would have ranked P3 as the worst press (3.93). The heatmap shows that P3 is ordinary from Tuesday to Saturday, averaging 3.04, and that its whole problem is Monday. The useful questions are about P3's Monday startup, not about P3 in general.
How to read the results
- Single cells that stand out point to a specific combination: one machine at one time.
- Full rows or columns point to one factor acting everywhere: a machine that is always worse, or a time slot that is bad for all.
- Blocks of similar color, after sorting, show groups of rows and columns that behave alike.
- Check the counts behind each cell. A rate based on few parts is noisy, and a dark cell may be chance. Confirm important cells with more data or a test such as cross tabulation and chi-square on the counts.
Common mistakes
- A rainbow color scale. Readers cannot tell whether yellow is higher than green; use a light-to-dark scale.
- Letting one outlier set the scale. Everything else turns the same color. Cap the scale or show the cell separately.
- Hiding the numbers. Colors give the pattern; print the values when the table is small enough, as here.
- Comparing maps with different scales. Two heatmaps side by side must share one legend.
- Mixing very different denominators. A cell built from 50 parts and one from 50,000 deserve different trust. Note low-volume cells.
Frequently asked questions
What is a heatmap used for in manufacturing?
To spot where and when problems concentrate: defects by machine and shift, downtime by line and week, temperature across zones, or correlations among process variables, as in a correlogram.
What is the difference between a heatmap and a contour plot?
A heatmap colors the cells of a table whose rows and columns may be categories. A contour plot shows a smooth response over two continuous variables, with lines of equal value.
Which color scale should I use?
Sequential (light to dark) for values from low to high; diverging (two hues around a neutral middle) for values above and below a reference, such as a target or zero.
Should I sort rows and columns?
Keep natural orders such as time. Otherwise, sort by averages or cluster similar rows so patterns form blocks.