When a treemap works for nested part-to-whole data, why area is hard to compare, how to label small rectangles, and when sorted bars are the better choice.
By DataVisuals TeamUpdated 5 min read
Best for
Showing how one total splits into groups and subgroups, such as a budget by department and team, or sales by category and product.
Avoid when
Readers need to rank or compare similar values precisely, or there is no hierarchy and only a few parts (use a sorted bar chart).
Data you need
One or more category columns that nest (group, then subgroup) and one positive numeric value per row.
A treemap fills a rectangle with smaller rectangles, each sized by its value. Groups are drawn as blocks, and each block is divided into its own parts. A company budget might show Engineering as one large block split into Platform, Mobile and Data teams, next to smaller blocks for Sales and Marketing.
It's good at one thing: showing the structure of a total with many parts, and where the big pieces are, in a small space. It's weak at precise comparison, because readers judge areas poorly, and rectangles with different shapes are even harder to compare than slices of a pie.
When to use a treemap
Use a treemap when your data has a hierarchy and the question is "where does the total go?" Good examples:
A budget by department and team
Sales by product category and product
Disk space by folder and file
Market value by sector and company
Website traffic by section and page
Treemaps handle dozens or even hundreds of items, which is where they beat a pie chart. Small items become tiny rectangles, but they don't break the chart the way slivers break a pie.
They only work for positive values that add up to something meaningful. Sales, costs, counts and time all work. Growth rates, averages and profit (which can be negative) do not.
How to read a treemap
Each rectangle's area is proportional to its value. Rectangles in the same group share a border and usually a color, and the group's total is the area of its whole block.
Fig. 1 A $95M budget split into five departments and their teams. Engineering takes the largest block. Within Marketing, Paid media is the biggest team, highlighted so the reader knows where to look.
Most tools use a "squarified" layout, which keeps rectangles as close to square as possible. Squares are easier to compare than long thin strips, and their labels fit better. The cost is that the layout ignores any natural order, so the position of a rectangle carries no meaning. Big items tend to land top-left and small ones bottom-right, but that is a side effect of sorting, not a rule readers can rely on.
Area is hard to judge
People compare lengths on a common baseline accurately and areas poorly. Asked whether one rectangle is twice as big as another, most readers guess low. When the rectangles also have different proportions, one tall and narrow, one short and wide, the judgment gets worse.
Fig. 2 Operating costs in seven categories. In the treemap, Software (14%) and Travel (12%) are hard to rank by eye. Sorted bars make the order and the gap obvious, and the small categories get readable labels too.
So use a treemap for the big picture ("Rent and payroll are well over half of costs") and not for close calls. If the story depends on telling 14% from 12%, print the numbers on the chart or use bars.
Rule of thumb: if your treemap has one level and fewer than about ten items, a sorted bar chart will be clearer.
Labeling a treemap
Labels make or break a treemap, and small rectangles have no room for them. A few practical rules:
Put the label in the top-left corner of each rectangle, with the name and value ("Platform 18").
Hide labels that don't fit instead of shrinking the text until it's unreadable. Tools can usually do this automatically.
Label the groups separately, with a heavier border around each group and the group name in its corner.
Make sure every item you mention in the text has a visible label, even if that means enlarging the chart.
Text color must contrast with the rectangle's fill. With a dark fill use light text, and with a light fill dark text. When colors vary by value, check the extremes.
Interactive treemaps can rely on tooltips for the small rectangles, but don't let that excuse a chart where nothing is labeled. A reader on a phone may never hover.
Color: groups or values
Color can do one of two jobs in a treemap, and mixing them confuses readers.
The first job is showing the groups. Each top-level category gets its own color, and its children share it, maybe in lighter or darker tones. This makes the hierarchy readable at a glance.
The second job is showing a second measure. Area shows size (market value, say) while color shows change (daily percentage move), usually with a diverging scale centered on zero. The well-known stock market treemaps work this way. When color shows a value, add a legend and use group borders to show the hierarchy.
In either case, keep a strong highlight color free for the one rectangle you want to talk about, as in the budget example above. The labels and annotations guide covers how to pair that highlight with a short note.
When a sorted bar chart is better
A treemap earns its place through hierarchy and volume. Without them, a bar chart wins.
Another honest option is to use both: a treemap to show the overall structure, followed by a sorted bar chart of the top items with exact numbers.
Common mistakes
Mistake
Why it hurts
Fix
Treemap for a handful of flat values
Area hides easy comparisons
Sorted bar chart
Three or more levels in a static chart
Rectangles too small to read
Two levels, or make it interactive
Unlabeled rectangles
Reader can't tell what anything is
Label all that fit, note the rest
Negative or average values
Area can't represent them
Use bars
Color for both groups and values
Mixed signals
Pick one job for color
Asking readers to rank similar areas
Area judgment is weak
Print values or use bars
A treemap answers "what is this total made of?" well and "which of these is bigger?" badly. Use it for the first question and pair it with bars for the second.
Questions
Can a treemap show negative values?
No. Rectangle area can't be negative, so a treemap only works for positive quantities that add up to a total. For profit and loss, use a bar chart with a zero line or a waterfall chart.
How many levels should a treemap have?
Two levels is usually the limit for a static chart. A third level makes rectangles too small to label. Interactive treemaps can go deeper by letting readers click into a group.
What is the difference between a treemap and a pie chart?
Both show parts of a whole, but a treemap fits many more parts in the same space and can show a hierarchy. Both rely on area, so neither is good for precise comparison.