How to Create a Heatmap: Complete Guide with Examples (2026)

Learn how to create heatmaps to visualize patterns, correlations, and intensity across two dimensions. Step-by-step guide with practical examples for business, science, and web analytics.

A heatmap turns a grid of numbers into a color-coded visual, making patterns, outliers, and correlations visible at a glance. Instead of scanning rows and columns of data, you read color intensity—darker means higher, lighter means lower.

Heatmaps are used everywhere: website analytics teams track where users click, data scientists visualize correlation matrices, and operations managers identify peak hours. If your data has two categorical or temporal axes and a numerical value at each intersection, a heatmap is likely the right chart.

In this guide, you'll learn what heatmaps are, when to use them, how to create one step by step, and the mistakes that make heatmaps misleading.

What Is a Heatmap?

A heatmap is a data visualization that represents values in a matrix using color gradients. Each cell in the grid corresponds to the intersection of two variables, and the cell's color indicates the magnitude of the value. Heatmaps make it easy to spot high-concentration areas, gaps, and patterns that would be invisible in a raw data table.

The concept dates back to the 19th century when manual shading was used on statistical maps. Today, heatmaps are generated digitally and are a core tool in data visualization. They work because human vision is highly attuned to color variation—we can detect subtle shade differences across hundreds of cells simultaneously.

When Should You Use a Heatmap?

Heatmaps are the right choice when your data fits a matrix structure—two dimensions with a numerical value at each intersection. They work well for:

  • Correlation analysis — Visualize how strongly variables relate to each other in a correlation matrix
  • Time-based patterns — Show activity levels across hours and days (e.g., website traffic by day of week and hour)
  • Geographic density — Display intensity across regions or zones
  • Performance comparison — Compare metrics across categories and time periods
  • User behavior analysis — Identify where users click, scroll, or spend time on a page

Heatmaps are not the best choice when you need to show exact values (use a bar chart), track trends over time (use a line chart), or compare parts of a whole (use a pie chart). For help picking the right chart type, see our chart types explained guide.

What Are the Different Types of Heatmaps?

Not all heatmaps look the same. The type you choose depends on your data and what you're trying to communicate.

Heatmap Type Best For Example
Correlation heatmap Showing relationships between variables Feature correlation matrix in a dataset
Calendar heatmap Displaying activity over days/weeks GitHub contribution graph
Clustered heatmap Grouping similar rows/columns together Gene expression analysis
Geographic heatmap Showing density across locations Sales intensity by region
Pivot table heatmap Cross-tabulating two categories Sales by product and quarter

Correlation heatmaps are particularly popular in data science and statistics. If you're exploring relationships between variables, you might also want to explore scatter plots for correlation analysis—scatter plots show individual data points while heatmaps summarize the strength of relationships across many variable pairs at once.

How to Create a Heatmap: Step by Step

There are several ways to create heatmaps, from no-code tools to full programming environments. Here are the most common methods.

Method 1: Use CleanChart (No Code Required)

The fastest way to create a heatmap without writing code or wrestling with spreadsheet formatting:

  1. Prepare your data as a matrix (rows, columns, and values) in CSV, Excel, or Google Sheets format
  2. Go to CleanChart's heatmap maker and upload your file
  3. Customize the color scale, labels, axis titles, and cell annotations
  4. Export as PNG, SVG, or PDF for presentations and reports

You can upload data directly from multiple sources:

If your data needs cleaning before visualization, our complete CSV data cleaning guide walks through the process step by step.

Method 2: Google Sheets

Google Sheets doesn't have a native heatmap chart type, but you can approximate one using conditional formatting:

  1. Select the range of numerical cells in your matrix
  2. Go to Format > Conditional formatting
  3. Choose Color scale and pick a gradient (e.g., white to green)
  4. Apply and adjust the min/max values as needed

This approach is limited—you get colored cells but not a proper chart with axes, legends, or export options. For a more polished result, export your Google Sheets data and use the Google Sheets to heatmap converter. See our Google Sheets to chart tutorial for more detailed guidance.

Method 3: Excel

Like Google Sheets, Excel uses conditional formatting for heatmap-style displays:

  1. Select your data range
  2. Go to Home > Conditional Formatting > Color Scales
  3. Choose a two-color or three-color gradient

For a true heatmap chart, you'll need to use Excel's surface chart or a third-party add-in. If you're weighing up the trade-offs between Excel and online tools, our Excel vs. online chart makers comparison breaks down the differences.

Method 4: Python (Seaborn / Matplotlib)

For programmers, Python's Seaborn library makes heatmaps straightforward:

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt

# Load and pivot your data
df = pd.read_csv("sales_data.csv")
pivot = df.pivot_table(index="day", columns="hour", values="revenue")

# Create the heatmap
sns.heatmap(pivot, annot=True, fmt=".0f", cmap="YlOrRd")
plt.title("Revenue by Day and Hour")
plt.tight_layout()
plt.savefig("heatmap.png", dpi=150)
plt.show()

The Seaborn heatmap documentation covers advanced options like masking, clustering, and custom color maps. If coding isn't your preference, our guide on creating charts without Python covers no-code alternatives.

How to Choose the Right Color Scale

Color is the backbone of a heatmap. A poor color choice can obscure patterns or mislead readers.

Sequential Scales (One Color)

Use a single-hue gradient (e.g., white to dark blue) when all values are positive and you want to show intensity from low to high. This is the most common choice for counts, revenue, and activity data.

Diverging Scales (Two Colors)

Use a two-color gradient (e.g., blue–white–red) when your data has a meaningful midpoint. Correlation matrices use this: blue for negative correlation, white for zero, red for positive. Temperature anomaly maps also use diverging scales.

Categorical Scales

If your heatmap cells represent distinct categories rather than a continuous range, use distinct colors. This is less common but useful for status grids (e.g., pass/fail/warning).

For in-depth guidance on selecting effective palettes, see our best color palettes for data visualization and the role of color in data visualization. If your audience may include people with color vision deficiency, our accessible charts for colorblind users guide covers safe palette choices.

Practical Heatmap Examples

Example 1: Website Traffic by Day and Hour

An e-commerce site wants to know when visitors are most active. The heatmap rows represent days of the week, columns represent hours (0–23), and color intensity shows page views. The result instantly reveals that Tuesday through Thursday from 10 AM to 2 PM has the highest traffic—prime time for promotions.

Example 2: Correlation Matrix for Sales Metrics

A sales team tracks 8 metrics: calls made, emails sent, meetings booked, proposals sent, deal size, close rate, cycle length, and revenue. A correlation heatmap shows which metrics move together. Strong positive correlation between meetings and revenue? That confirms the team should prioritize booking meetings. This type of analysis pairs well with scatter plots for drilling into specific pairs.

Example 3: Product Performance Across Regions

A consumer goods company sells 6 products across 10 regions. The heatmap rows show products, columns show regions, and color shows units sold. Instantly visible: Product D dominates in the Northeast but barely registers in the Southwest. This drives regional marketing strategy. For broader sales visualization techniques, see our sales data visualization guide.

Heatmap Best Practices

  1. Annotate cells with values when the grid is small. If you have fewer than 100 cells, adding the actual number inside each cell gives viewers both the color overview and the precise data.
  2. Always include a color legend. Without a legend, readers have to guess what the colors mean. Position it adjacent to the chart for easy reference.
  3. Sort rows and columns meaningfully. Alphabetical order rarely reveals patterns. Sort by totals, by time, or use clustering to group similar rows together.
  4. Normalize data when comparing across different scales. If one row has values from 0–100 and another from 0–10,000, the second row will dominate the color scale. Normalize to percentages or z-scores for fair comparison.
  5. Keep axis labels readable. Rotate or abbreviate labels that overlap. Unreadable labels defeat the purpose of the visualization. For more chart formatting advice, see why your chart looks wrong.

Common Mistakes to Avoid

Mistake 1: Using Too Many Colors

Rainbow color scales (red–orange–yellow–green–blue–purple) look vibrant but are perceptually non-uniform—the human eye doesn't interpret them as a smooth gradient. Stick to sequential or diverging scales with one or two hues.

Mistake 2: Ignoring Missing Data

Empty cells in your matrix can break the color scale or be misinterpreted as zero. Always handle missing values explicitly: either fill them, mark them with a distinct color (e.g., gray), or annotate them as "N/A."

Mistake 3: Overcrowding the Grid

A heatmap with 200 rows and 50 columns becomes an unreadable blur on screen. If your matrix is very large, aggregate or filter before plotting. Group weeks into months, or show the top 20 rows instead of all 200.

Mistake 4: Skipping Normalization

Comparing raw counts across categories of vastly different sizes is misleading. A large region will always look "hot" simply because it has more data. Normalize to rates, percentages, or per-capita values to make fair comparisons.

Mistake 5: No Title or Context

A heatmap without a title, axis labels, or color legend is a colored grid with no meaning. Always provide context so the reader knows what they're looking at and what the colors represent.

Heatmap vs. Other Chart Types: When to Use What?

Question You're Answering Best Chart Why Not a Heatmap?
How does revenue trend over 12 months? Line chart Heatmaps don't show continuous trends well
Which product sold the most? Bar chart Bar length is easier to compare than color shade
What share does each region hold? Pie chart Heatmaps don't show part-to-whole relationships
Are two variables correlated? Scatter chart or heatmap Scatter for two variables; heatmap for many pairs
How is activity distributed across day and hour? Heatmap This is exactly what heatmaps excel at
What does the data distribution look like? Histogram or box plot Heatmaps show matrix data, not distributions

Frequently Asked Questions

What data format do I need for a heatmap?

Heatmaps require matrix-structured data: rows represent one dimension (e.g., products), columns represent another (e.g., months), and each cell contains a numerical value. You can supply this as a CSV file, Excel spreadsheet, JSON object, or Google Sheet. If your data is in long format (one row per observation), pivot it first so each row-column combination maps to one value.

How many rows and columns can a heatmap handle?

Practically, heatmaps work best with up to about 50 rows and 50 columns on screen. Beyond that, individual cells become too small to distinguish. For larger datasets, filter to the most relevant subset, aggregate into broader categories, or use interactive zoom.

What is a correlation heatmap?

A correlation heatmap displays the Pearson correlation coefficients between all pairs of numerical variables in a dataset. Values range from −1 (perfect negative correlation) to +1 (perfect positive correlation), with 0 meaning no linear relationship. A diverging color scale (e.g., blue–white–red) makes it easy to spot strong positive and negative correlations. For more on correlation analysis, see our correlation charts and scatter plots guide.

Can I create a heatmap in Google Sheets?

Google Sheets doesn't have a dedicated heatmap chart type, but you can use conditional formatting with color scales to create a heatmap effect on cells. For a proper heatmap chart with a legend, axes, and export options, use the Google Sheets to heatmap converter in CleanChart. Our Google Sheets to chart tutorial covers the full workflow.

What color palette works best for heatmaps?

For sequential data (all positive values), use a single-hue gradient like white-to-blue or white-to-green. For diverging data (positive and negative, like correlations), use a two-hue gradient like blue-white-red. Avoid rainbow palettes—they're perceptually uneven and misleading. See our color palettes guide for specific recommendations.

How is a heatmap different from a choropleth map?

Both use color to encode values, but a choropleth map uses geographic boundaries (countries, states, zip codes), while a heatmap uses a regular grid. Choropleth maps are a geographic subtype of the heatmap concept. If your data isn't geographic, a standard grid heatmap is what you need.

Create Your First Heatmap

Heatmaps transform dense numerical matrices into intuitive color-coded visuals. Whether you're analyzing correlations, spotting peak activity times, or comparing performance across categories, a heatmap reveals patterns that tables hide.

Ready to try it? Create a heatmap with CleanChart—upload your data from CSV, Excel, JSON, or Google Sheets and get a publication-ready chart in under a minute.

Related CleanChart Resources

External Resources

Last updated: February 9, 2026

Ready to Create Your First Chart?

No coding required. Upload your data and create beautiful visualizations in minutes.

Create Chart Free