Heat Maps Explained

โฑ๏ธ 90 sec read ๐Ÿ“Š Visualization

A heatmap is a grid where each cell is colored by its value, so patterns in a large matrix of numbers become visible at a glance. It shows where values are high or low across two dimensions - not exact numbers, but hot spots, cold spots, clusters, and outliers.

What Does a Heatmap Show?

A heatmap shows the intersection of two categorical or ordered dimensions (rows and columns) with a third quantitative value encoded as color. It answers questions like "which day-hour combinations get the most traffic?" faster than any table of numbers could.

Example: Website traffic by day and hour

        Mon  Tue  Wed  Thu  Fri  Sat  Sun
9AM     ๐ŸŸฆ   ๐ŸŸฆ   ๐ŸŸฆ   ๐ŸŸฆ   ๐ŸŸฆ   ๐ŸŸฉ   ๐ŸŸฉ
12PM    ๐ŸŸจ   ๐ŸŸจ   ๐ŸŸจ   ๐ŸŸจ   ๐ŸŸจ   ๐ŸŸง   ๐ŸŸง
3PM     ๐ŸŸง   ๐ŸŸง   ๐ŸŸง   ๐ŸŸง   ๐ŸŸง   ๐ŸŸฅ   ๐ŸŸฅ
6PM     ๐ŸŸฅ   ๐ŸŸฅ   ๐ŸŸฅ   ๐ŸŸฅ   ๐ŸŸฅ   ๐ŸŸจ   ๐ŸŸจ

Pattern instantly visible: weekends have
different traffic, 3PM-6PM is busiest

When Should You Use a Heatmap?

Use a heatmap when you have matrix-shaped data (two dimensions crossed) with 50+ cells and the goal is spotting patterns rather than reading precise values. Below ~20 cells a table beats it; for one dimension, use a bar chart.

Skip heatmaps for precise value reading (humans can't tell 47% from 49% by color), tiny datasets, single-dimension data, or unordered categories where no spatial pattern can emerge. Ready to build one? Follow the step-by-step guide to making a heatmap in Python and Excel.

Sequential vs Diverging: Which Color Scale?

Use a sequential scale (light-to-dark, single hue) when data runs from low to high with no meaningful midpoint, and a diverging scale (two hues meeting at a neutral center) when there's a natural zero, average, or target. Picking the wrong one is the most common heatmap mistake.

SEQUENTIAL (light blue -> dark blue):
- Sales volume, traffic, population density
- Light = low, dark = high

DIVERGING (red <- white -> blue):
- Profit/loss (zero midpoint)
- Correlation (-1 to +1, zero midpoint)
- Performance vs target (target midpoint)
- Temperature change (average midpoint)

Never use rainbow scales, and avoid red-green diverging pairs (about 8% of men can't distinguish them). Use 5-9 distinct steps, test the chart in grayscale, and label the legend with min/max and units. For picking specific ramps, see choosing color palettes.

Should You Normalize Heatmap Rows or Columns?

Normalize by row or column whenever one row or column has much larger raw values than the rest, because otherwise it dominates the color scale and flattens every other pattern into pale nothing. Convert each row (or column) to percentages, z-scores, or an index against its own mean, then color the normalized values.

Raw values: "Which cell is biggest overall?"
Row %:      "How does each product distribute
             across regions?"
Column %:   "What is each region's product mix?"
Z-score:    "Which cells are unusual for
             their row?"

The same logic handles outliers: one extreme value can crush the rest of the scale. Fix it by capping colors at the 95th percentile, using a log scale, or marking outliers separately. In seaborn that's one argument: sns.heatmap(df, robust=True).

What Is a Correlation Matrix Heatmap?

A correlation matrix heatmap colors every pairwise correlation between variables on a diverging scale from -1 to +1, making related variables jump out of what would otherwise be an unreadable grid of decimals. It's the standard first look at any dataset with many numeric columns.

Example: Stock correlations
         AAPL  MSFT  GOOG  AMZN
AAPL     1.0   0.8   0.7   0.6
MSFT     0.8   1.0   0.9   0.7
GOOG     0.7   0.9   1.0   0.8
AMZN     0.6   0.7   0.8   1.0

# Python one-liner:
sns.heatmap(df.corr(), cmap="RdBu_r",
            vmin=-1, vmax=1, annot=True)

Always pin the scale to vmin=-1, vmax=1 with a neutral color at zero, and consider masking the redundant upper triangle since the matrix is symmetric.

What Is a Calendar Heatmap?

A calendar heatmap arranges days into a calendar grid (weeks ร— weekdays) and colors each day by activity - the GitHub contribution graph is the famous example. It's the best format for spotting weekly rhythms, streaks, and seasonal patterns in daily data.

Layout: columns = weeks, rows = Mon-Sun
Color:  commits, sales, workouts, sign-ups

Use cases: habit tracking, daily sales
patterns, support ticket volume, user
activity over a year

What Other Heatmap Types Exist?

Beyond matrix, correlation, and calendar heatmaps, the two other common variants are geographic heatmaps (density blobs over a map - distinct from choropleths, which color whole regions by value) and cluster heatmaps, where rows and columns are reordered by similarity so related items group together, standard in gene expression and customer segmentation work.

Heatmap Design Best Practices

Good heatmaps come down to meaningful ordering, readable cells, and honest legends; the color scale does the rest of the work.

Common Heatmap Mistakes

Four failures account for most bad heatmaps: a sequential scale on diverging data, an outlier crushing the color range, too many cells to read, and unequal legend bins.

Heatmap Alternatives

If your audience needs exact values, has a small dataset, or only one dimension, another chart serves better than a heatmap.

If You Need Use Instead
Exact values Table with conditional formatting
Small dataset (< 20 cells) Bar chart or table
Single dimension Bar chart or line chart
Geographic distribution by region Choropleth map

Quick Checklist Before Publishing

Run this list before shipping any heatmap; every item maps to one of the mistakes above.

Golden Rule: Heat maps are for spotting patterns, not reading exact values. If your audience needs precise numbers, add tooltips or use a table instead. If the pattern doesn't jump out within 3 seconds, your color scale or ordering is wrong.

โ† Back to Visualization Tips