A heatmap is a data visualization that represents values in a two-dimensional grid of cells, with each cell colored according to its magnitude. In visualization, it is used to show how a measure varies across two categorical or binned dimensions at once, such as hour by weekday, product by region or variable by variable, so that patterns, clusters and outliers become visible without reading individual numbers.
The effectiveness of a heatmap depends less on the grid than on the color scale: how values are mapped to hues and lightness, where the scale starts and ends, and whether the colors remain distinguishable for every reader.
How a heatmap encodes data
A heatmap encodes data by placing one dimension on the rows, another on the columns and mapping the value of each cell to a color. The reader compares cells by color rather than by position or length, which makes heatmaps excellent for spotting broad structure and weaker for reading exact values.
Building one involves three decisions: aggregating raw data into cells (for example, counting events per hour and weekday), choosing a color scale and deciding on row and column order. Ordering matters because similar rows placed next to each other form visible blocks, while an arbitrary order scatters the same pattern into noise.
The table below lists the components that every heatmap specification should define.
| Component | Role | Typical choices |
|---|---|---|
| Row dimension | Groups shown vertically | Categories, entities, time bins |
| Column dimension | Groups shown horizontally | Categories, periods, variables |
| Cell value | Measure being compared | Count, mean, rate, correlation |
| Color scale | Maps values to colors | Sequential, diverging, categorical |
| Legend | Explains the mapping | Continuous bar or labeled steps |
| Ordering | Arranges rows and columns | Natural order, sorted, clustered |
Types of heatmaps and color scales
Heatmaps vary by what the grid represents. The term covers several related forms, and choosing the right color scale type for each is the most important design decision.
| Type | What the grid shows | Typical use |
|---|---|---|
| Matrix heatmap | Two categorical dimensions | Sales by product and region |
| Calendar heatmap | Days arranged in weeks | Daily activity over a year |
| Correlation matrix | Variables against variables | Exploring relationships before modeling |
| Clustered heatmap | Rows and columns reordered by similarity | Gene expression, customer segments |
| Density heatmap | Binned two-dimensional numeric data | Dense scatter data with overplotting |
A sequential scale runs from light to dark in one hue and suits values that go from low to high, such as counts. A diverging scale uses two hues around a meaningful midpoint and suits values with a natural center, such as correlation coefficients from -1 to +1 or change against a target. Using a sequential scale for diverging data hides the midpoint, and using a diverging scale without a real midpoint invents one.
Perceptually uniform color maps, in which equal steps in value look like equal steps in color, avoid false boundaries. The traditional rainbow color map fails this test: bright yellow and cyan bands draw the eye to arbitrary values and make some ranges look flatter than they are.
Heatmaps compared with other chart types
A heatmap trades precision for overview. Position along a common axis, as in a bar chart or line chart, is read far more accurately than color, so a heatmap is the better choice only when the number of cells is too large for those charts to remain legible.
| Chart | Best at | Weakness compared with a heatmap |
|---|---|---|
| Heatmap | Patterns across two dimensions | Imprecise reading of single values |
| Bar chart | Exact comparison of a few categories | Becomes cluttered beyond one dimension |
| Line chart | Trends over continuous time | Many overlapping lines are hard to read |
| Scatter plot | Relationship between two numeric variables | Overplotting with very many points |
| Histogram | Distribution of one variable | Shows only one dimension |
Within a dashboard, heatmaps work well as a navigation layer: a reader spots an unusual cell, then drills into a line chart or table for the exact figures. Adding the numeric value inside each cell helps when the grid is small, roughly up to a few hundred cells, but makes larger grids unreadable.
Designing a readable heatmap
A readable heatmap results from a few deliberate choices about scale, order and labeling. The decision table below summarizes the most common situations.
| Situation | Recommended choice | Reason |
|---|---|---|
| Values from zero upward | Sequential single-hue scale | Darker reads naturally as more |
| Values around a target or zero | Diverging scale centered on it | Shows direction and size of deviation |
| A few extreme outliers | Capped or quantile-based scale | Prevents outliers washing out the rest |
| Unknown structure in many rows | Hierarchical clustering order | Groups similar rows into blocks |
| Audience includes color vision deficiency | Lightness-based or tested palette | Avoids red-green confusion |
Labels should include the unit and aggregation in the legend (for example, “median minutes per order”), and empty cells should be visually distinct from zero. A missing value shown in the lightest color will be read as a real low value, which is one of the most damaging and least noticed errors.
Limitations and common mistakes
The central limitation of a heatmap is that humans judge color poorly in absolute terms. The same shade looks different depending on its neighbors, so two cells far apart on the grid are hard to compare reliably.
- Unequal group sizes: raw counts make large groups look hot simply because they are large, so rates or normalized values are often more honest.
- Arbitrary binning of continuous data, where changing the bin width can create or erase apparent patterns.
- Misleading scale limits, such as a scale that starts above zero and exaggerates small differences.
- Overinterpreting clustering, since clustered order will always produce some blocks, even in random data.
- Unrelated heatmaps sharing different scales side by side, which invites false comparison.
A non-technical view
A heatmap is a table where the numbers are replaced by colors. Instead of reading every figure, you look at the whole grid and see at once where things are high and where they are low.
Think of a weather map that shades hot regions red and cool regions blue. You do not need the exact temperature of each town to see that the south is warmer. A heatmap does the same for any kind of data. The main thing to remember is that it is good for spotting patterns quickly, while the exact numbers still belong in a table or chart.
A concrete example
A city bike-sharing operator wants to plan when to move bikes between stations. Analysts count rentals for each hour of the day across the seven weekdays over six months and display the result as a 24-by-7 heatmap with a sequential blue scale.
The grid shows two dark bands on weekdays, around 8:00 and between 17:00 and 18:00, and a broad lighter area on weekend afternoons. A diverging version comparing each station with the citywide average reveals that several stations near the main railway station run well above average in the morning peak. The operator schedules redistribution trucks before 7:30 on weekdays, and the share of trips that could not start because a station was empty drops noticeably in the following month.