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

Learn how to create treemaps to visualize hierarchical data, budget breakdowns, and market composition. Step-by-step guide with practical examples for business, product, and portfolio analysis.

A treemap packs an entire hierarchy into a single rectangle. Each nested box represents a branch of the tree, and its size shows how much of the total it accounts for. No scrolling through tables, no collapsing tree views—the whole picture is right there.

Treemaps are the go-to chart when you need to show composition across many categories and sub-categories at once. Product managers use them to see which features drive the most usage. Finance teams use them to break down budgets by department, team, and line item. Analysts use them to visualize market share across dozens of competitors.

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

What Is a Treemap?

A treemap is a data visualization that displays hierarchical data as a set of nested rectangles. Each rectangle (called a "tile") represents a data point, and its area is proportional to a quantitative value—typically size, revenue, count, or percentage. Tiles can be grouped and nested to show parent-child relationships in the hierarchy.

The concept was invented by Ben Shneiderman at the University of Maryland in 1990, originally to visualize disk space usage on a hard drive. Today, treemaps are used across business intelligence, finance, product analytics, and data journalism. They work because our visual system is highly attuned to area differences—we can quickly spot which rectangles dominate and which are tiny, even across hundreds of tiles.

If you're new to data visualization in general, our beginner's guide to data visualization covers the fundamentals before you dive into treemaps.

When Should You Use a Treemap?

Treemaps are the right choice when your data is hierarchical and you want to show how parts relate to the whole across many categories. They excel at:

  • Budget and expense breakdowns — Show how a total budget splits into departments, then teams, then line items
  • Market share analysis — Display the relative size of competitors, product categories, or geographic markets
  • Portfolio composition — Visualize investment allocations by sector, industry, and individual holding
  • Disk or storage usage — The original use case—see which folders and files consume the most space
  • Product catalog analysis — Identify which product lines, categories, and SKUs generate the most revenue
  • Website content audit — Map page views by section, subsection, and individual URL

Treemaps are not the best choice when you need to compare exact values (use a bar chart), track trends over time (use a line chart), show simple part-to-whole with few categories (use a pie chart or donut chart), or visualize relationships between variables (use a scatter plot). For help choosing the right chart, see our chart types explained guide.

Treemap vs. Other Charts: When to Use What?

Treemaps overlap with several other chart types. Here's how to choose.

Question You're Answering Best Chart Why Not a Treemap?
What share does each of 3–5 categories hold? Pie chart Pie charts are simpler for few categories
How do 10+ categories compare in size? Bar chart or treemap Bar charts show exact values better; treemaps show hierarchy
How does a total break down into nested sub-groups? Treemap This is exactly what treemaps are built for
How does revenue trend over time? Line chart or area chart Treemaps show a snapshot, not trends
Which region has the highest intensity? Heatmap Heatmaps use a grid layout; treemaps use nested rectangles
What is the data distribution? Histogram or box plot Treemaps show composition, not distribution
How do sequential changes add up? Waterfall chart Waterfall shows step-by-step changes; treemaps show final composition

How to Create a Treemap: Step by Step

There are several ways to create treemaps, from no-code tools to full programming environments.

Method 1: Use CleanChart (No Code Required)

The fastest way to create a treemap without writing any code:

  1. Prepare your data with at least two columns: a category label and a numerical value. For nested treemaps, add parent-category columns.
  2. Go to CleanChart's treemap maker and upload your file
  3. Map your columns to the hierarchy levels and size metric
  4. Customize colors, labels, borders, and tooltip content
  5. Export as PNG, SVG, or PDF for presentations and reports

You can upload data 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 has a built-in treemap chart type:

  1. Structure your data with columns for each hierarchy level (e.g., Region, Country, City) and a Value column
  2. Select your data range
  3. Go to Insert > Chart
  4. In the Chart editor, change the chart type to Treemap chart
  5. Adjust colors and labels in the Customize tab

Google Sheets treemaps are functional but limited in styling and export options. For more polished results, export your data and use the Google Sheets to treemap converter. See our Google Sheets to chart tutorial for the full workflow.

Method 3: Excel

Excel 2016 and later versions include a treemap chart type:

  1. Organize your data in a table with hierarchy columns and a value column
  2. Select your data range
  3. Go to Insert > Charts > Treemap
  4. Customize colors and labels using the Chart Design and Format tabs

Excel's treemap is good for quick internal use but limited for publication-quality output. If you're evaluating options, our Excel vs. online chart makers comparison breaks down the trade-offs. For the best export quality, see our publication-ready charts guide.

Method 4: Python (Plotly / Squarify)

For programmers, Python offers excellent treemap libraries:

import plotly.express as px
import pandas as pd

# Load your hierarchical data
df = pd.read_csv("revenue_by_product.csv")

# Create a treemap with Plotly
fig = px.treemap(
    df,
    path=["Region", "Category", "Product"],
    values="Revenue",
    color="Growth",
    color_continuous_scale="RdYlGn",
    title="Revenue Breakdown by Region, Category, and Product"
)
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
fig.write_image("treemap.png", scale=2)
fig.show()

The Plotly treemap documentation covers advanced features like custom hover templates, color mapping, and animation. If coding isn't your preference, our guide on creating charts without Python covers no-code alternatives.

How to Structure Data for a Treemap

Treemaps require hierarchical data. There are two common formats:

Flat Table (Most Common)

Each row represents a leaf node. Parent categories are columns:

DepartmentTeamProjectBudget
EngineeringFrontendDashboard150000
EngineeringFrontendMobile App120000
EngineeringBackendAPI200000
MarketingContentBlog50000
MarketingContentVideo80000
MarketingPaidGoogle Ads100000

This format works directly with CleanChart, Excel, Google Sheets, and Plotly. The tool automatically groups rows by the parent columns to build the tree.

Parent-Child Format

Each row defines one node and its parent:

IDParentLabelValue
1Total Budget
21Engineering
32Frontend270000
42Backend200000
51Marketing
65Content130000
75Paid100000

This format is more flexible for deeply nested trees but requires more setup. Most tools accept the flat table format, so use that unless your hierarchy has more than 3–4 levels.

If your data has missing values or inconsistent category names, clean it first using our guide to handling missing values in CSV files. Common issues like "Marketing" vs. "marketing" or blank parent cells will break the hierarchy.

Practical Treemap Examples

Example 1: Company Budget Breakdown

A CFO needs to present the annual budget to the board. The treemap shows three levels: department > team > expense category. At a glance, the board sees that Engineering consumes 45% of the budget, with the Backend team's cloud infrastructure costs as the single largest tile. No spreadsheet could communicate this as quickly. For more on financial chart techniques, see our sales data visualization guide.

Example 2: E-Commerce Product Revenue

An e-commerce company sells 500 products across 8 categories and 30 sub-categories. A bar chart with 500 bars is unreadable. A treemap groups products by category > sub-category > individual product, with tile size showing revenue. The product manager instantly sees that "Electronics > Accessories > Phone Cases" is the highest-revenue SKU—and that the entire "Home & Garden" category is smaller than a single electronics sub-category.

Example 3: Stock Market Sector Map

Financial news sites use treemaps to show daily stock market performance. Each tile represents a stock, grouped by sector and industry. Tile size shows market cap, and color shows daily price change (green for up, red for down). This is the visualization behind popular tools like Finviz's S&P 500 map. It communicates more about market conditions in a single glance than any table or list could.

Example 4: Website Traffic by Section

A content team wants to understand which areas of their website attract the most visitors. The treemap shows section > sub-section > individual page, with tile size proportional to page views. The visualization reveals that the blog section dominates traffic, but within it, just 5 articles account for 60% of all blog views. This analysis pairs well with heatmap visualizations for understanding user behavior on individual pages.

Treemap Best Practices

  1. Limit hierarchy depth to 2–3 levels. Deeper nesting makes tiles too small to label or interact with. If you have more levels, consider showing only the top 2–3 and providing drill-down capability.
  2. Use color to encode a second variable. Size already represents one metric (e.g., revenue). Use color to show a second metric (e.g., growth rate: green for growing, red for declining). This doubles the information density.
  3. Label the largest tiles directly. Small tiles can rely on tooltips, but large tiles should have visible text labels. Ensure labels are legible against the background color.
  4. Sort tiles by value within each group. Most treemap algorithms do this automatically, but verify that the largest tile appears in the top-left corner of each group. This creates a predictable reading pattern.
  5. Include a legend and title. Without context, a treemap is just a collection of colored rectangles. Always explain what size represents, what color represents, and what the hierarchy levels are.
  6. Use distinct borders between hierarchy levels. A thick border around top-level groups and thinner borders within helps viewers parse the structure. Without borders, the hierarchy is invisible. For color guidance, see our guide on color in data visualization.

Common Mistakes to Avoid

Mistake 1: Too Many Tiny Tiles

A treemap with 500 leaf nodes where 400 of them are slivers is hard to read. Filter out the smallest items or aggregate them into an "Other" category. The goal is to make every visible tile large enough to convey information.

Mistake 2: Meaningless Color

Assigning random colors to tiles wastes a valuable data channel. Either map color to a meaningful variable (growth rate, performance, category) or use a single hue with varying saturation. Random color is just visual noise. For palette recommendations, see our data visualization color palettes guide.

Mistake 3: No Hierarchy Borders

Without visible borders separating hierarchy levels, viewers can't tell which tiles belong to which parent group. Use thick borders or whitespace between top-level groups to make the structure obvious.

Mistake 4: Using Treemaps for Time-Series Data

Treemaps show a single point in time. They cannot show trends, growth, or change over time. If you need temporal analysis, use a line chart or area chart. For time-series best practices, see our time series charts guide.

Mistake 5: Comparing Treemaps Side by Side

Comparing two treemaps to spot differences is very difficult because tile positions and proportions change. For before/after comparisons, use grouped or stacked bar charts instead, or use a waterfall chart to show the changes directly.

When Should You NOT Use a Treemap?

Treemaps are powerful but not universal. Avoid them when:

  • You have fewer than 7 categories — A pie chart or bar chart is simpler and more effective
  • Exact values matter more than proportions — Human perception of area is less accurate than length; use bar charts for precision
  • Your data isn't hierarchical — Flat categorical data is better shown with bar charts. Treemaps need at least two levels.
  • You need to show change over time — Use line charts or area charts
  • Your audience is unfamiliar with treemaps — In some contexts, a simple bar chart is understood faster, even if it carries less information

How to Make Treemaps Accessible

Treemaps present accessibility challenges because they rely heavily on color and area. To make yours inclusive:

  • Use colorblind-safe palettes. Avoid red-green combinations. Use blue-orange or other safe pairs. See our guide to colorblind-friendly charts for specific palette recommendations.
  • Add text labels to all tiles large enough to display them. Screen readers and users with color vision deficiency rely on text.
  • Provide an alternative data table. Include a sortable table below or linked from the treemap so all users can access the underlying data.
  • Use tooltips with complete information. On hover or focus, show the full hierarchy path, value, and percentage of total.

Frequently Asked Questions

What data format do I need for a treemap?

Treemaps need hierarchical data with at least two columns: a category label and a numerical value. For nested treemaps, add columns for each hierarchy level (e.g., Department, Team, Project). You can supply this as a CSV file, Excel spreadsheet, or Google Sheet. The flat table format (one row per leaf node) is the most common and widely supported.

How many categories can a treemap handle?

Treemaps can technically display thousands of tiles, but readability drops after about 100–200 visible tiles on a standard screen. For larger datasets, aggregate the smallest items into an "Other" category or provide interactive drill-down. The strength of treemaps is showing many categories at once, which makes them preferable to pie charts (which struggle beyond 7 categories).

What is the difference between a treemap and a pie chart?

Both show parts of a whole, but treemaps handle hierarchy and scale better. A pie chart works well for 3–7 categories with no nesting. A treemap handles dozens or hundreds of categories organized in a tree structure. Treemaps also use screen space more efficiently—rectangles tile without gaps, while pie slices leave empty corners.

Can I create a treemap in Excel?

Yes. Excel 2016 and later include a built-in treemap chart type under Insert > Charts. However, Excel treemaps have limited customization. For more control over colors, labels, and export formats, use CleanChart's treemap maker or a Python library. Our Excel vs. online chart makers comparison covers the trade-offs in detail.

Can I create a treemap from a Google Sheet?

Yes. Google Sheets has a native treemap chart type. For a more polished result with better export options, use the Google Sheets to treemap converter in CleanChart. Our Google Sheets to chart tutorial walks through the full process.

How do treemap tiling algorithms work?

Treemap algorithms divide a rectangle into smaller rectangles proportional to data values. The most common algorithms are squarified (produces tiles close to square for better readability), slice-and-dice (alternates horizontal and vertical splits), and binary tree (recursively splits data into two balanced groups). Most tools use squarified by default because it produces the most readable layouts. For a deeper dive, see the Wikipedia article on treemapping algorithms.

How should I choose colors for a treemap?

Use color to encode a meaningful second variable (e.g., growth rate, performance tier). For sequential data, use a single-hue gradient (light to dark). For diverging data (positive/negative), use a two-hue scale (e.g., green for positive, red for negative). If color represents categories rather than values, use distinct but muted hues. Avoid rainbow palettes. See our color palettes guide for specific recommendations.

Create Your First Treemap

Treemaps turn complex hierarchies into a single, scannable visual. Whether you're breaking down a budget, mapping market share, or auditing content performance, a treemap shows the big picture and the details at the same time.

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

Related CleanChart Resources

External Resources

Last updated: February 10, 2026

Ready to Create Your First Chart?

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

Create Chart Free