Try it on your own data
Every report in this article is in the free plan. One snippet for web and apps, up to 10 sites.
Start freeTreemap visualization shows a hierarchy as nested rectangles whose areas match values, so you see each group's share and what is inside it. Use it for part-to-whole across a hierarchy with many categories. To rank or compare a modest number of values, a sorted bar chart is easier to read accurately.
What you will learn
- Use a treemap only for additive, non-negative values with a hierarchy you want to see
- People judge area less accurately than position; in experiments bars beat treemaps for leaf values at lower item counts
- Squarified layouts avoid slivers: in the sample the worst rectangle is 2.4 to 1 instead of about 42 to 1
What is a treemap?
A treemap shows a hierarchy as nested rectangles. Each rectangle's area is proportional to a value, and a parent rectangle contains its children, so you see the share of each group and what makes it up in one picture. A website example: a rectangle per channel, subdivided into a rectangle per source.
The idea came to Ben Shneiderman in 1990, when an 80 MB disk shared by 14 users in his lab was filling up and it was hard to see where the space went. The University of Maryland's history of treemaps dates the first technical report to March 1991 and the journal paper to January 1992.
The rest of this guide makes one argument: a treemap earns its place when you need part-to-whole across a hierarchy with many categories; when the job is comparing a modest number of values, a sorted bar chart reads better. Perception research says why, and one set of traffic data drawn both ways shows it.
When is a treemap the right chart?
Answer four questions in order:
| Question | If yes | If no |
|---|---|---|
| Do the values add up to a meaningful total? | Continue | Use bars or a table; area implies parts of a whole |
| Are all values zero or positive? | Continue | Use a diverging bar chart; a rectangle cannot have negative area |
| Is there a hierarchy you want to see (group, then item)? | Continue | A sorted bar chart is simpler |
| Are there too many items for a readable list, or do group totals matter most? | A treemap fits | Use a sorted bar chart, grouped by parent |
Typical good cases are storage by folder, spend by department and line item, catalog revenue by category and product, or traffic by channel, source and campaign when there are hundreds of campaigns. Weak cases are five categories, growth rates, anything that changes sign and any chart whose point is a trend over time.
| Your situation | Chart to use |
|---|---|
| Five to a few dozen items to rank | Sorted bar chart |
| Two levels, group totals matter | Treemap, or two linked bar charts |
| Hundreds to thousands of items, hunting the big ones | Treemap |
| Values that can be negative | Diverging bar chart |
| Mix across several periods | 100% stacked bars |
| Two measures per item | Scatter plot |
When two charts both fit, pick the one that makes the most frequent question readable without labels.
The same traffic data as a treemap and a sorted bar
Sample data: one month, 40,000 sessions, 7 channels and 21 sources. In a treemap drawn in an 800 × 500 pixel box, each channel gets an area equal to its share of 400,000 square pixels.
| Channel | Sessions | Share | Sources inside | Area in an 800 × 500 box |
|---|---|---|---|---|
| Organic search | 16,000 | 40% | 4 | 160,000 px² |
| Direct | 8,400 | 21% | 1 | 84,000 px² |
| Referral | 5,200 | 13% | 5 | 52,000 px² |
| Social | 4,600 | 11.5% | 4 | 46,000 px² |
| 3,200 | 8% | 3 | 32,000 px² | |
| Paid | 2,000 | 5% | 2 | 20,000 px² |
| AI assistants | 600 | 1.5% | 2 | 6,000 px² |
Now the same data as a bar list of sources, sorted, top eight shown:
| Rank | Source (channel) | Sessions | Share | Cumulative |
|---|---|---|---|---|
| 1 | Search engine A (organic) | 13,200 | 33.0% | 33.0% |
| 2 | Direct | 8,400 | 21.0% | 54.0% |
| 3 | Newsletter (email) | 2,100 | 5.3% | 59.3% |
| 4 | Partner blog (referral) | 1,900 | 4.8% | 64.0% |
| 5 | Social network A (social) | 1,800 | 4.5% | 68.5% |
| 6 | Search engine B (organic) | 1,600 | 4.0% | 72.5% |
| 7 | News site (referral) | 1,300 | 3.3% | 75.8% |
| 8 | Social network B / Search ads (tie) | 1,200 each | 3.0% each | 81.8% |
In the treemap you see at a glance that organic search is the largest block, that one engine fills most of it, and that referral is made of several mid-sized sources. In the bar list you see the ranking and the gaps. Try one question on each: is the partner blog bigger than social network A? The difference is 1,900 against 1,800, about 5% of the larger value. On two aligned bars that is a visible step. In a treemap the two rectangles sit in different parent boxes with different shapes, and most readers will need the labels.
The smallest source, assistant B with 200 sessions, gets 0.5% of the box: 2,000 px², a square about 45 pixels wide. On a 320 × 200 pixel phone chart it gets 320 px², about 18 pixels square, with no room for a name.
Sample month by channel
sessions, 40,000 totalWhich chart wins for which task?
| Task | Better choice | Why |
|---|---|---|
| Spot the largest one or two items | Either | Big differences survive any encoding |
| Rank items or compare two close values | Sorted bar chart | Position and length on a shared baseline are judged more accurately than area |
| See how groups make up the total | Treemap | Parts and parents are visible together |
| Compare one group total with another | Treemap, or bars of group totals | In a treemap the total is already drawn; with item bars the reader must add |
| Read exact values | Table | No chart beats a number |
| See change over time | Line or stacked area | Treemap rectangles move when values change |
| Scan thousands of items for the big ones | Treemap | Many small marks still fit on screen |
For other question types, website traffic graphs maps common questions to chart types, and how to create a bar graph covers axis rules.
What does perception research say about area?
Two studies are worth knowing.
Jeffrey Heer and Michael Bostock replicated Cleveland and McGill's classic experiments with online participants and extended them to areas. Position judgments significantly outperformed length judgments, and area judgments did worse than angle judgments, with both significantly worse than position. Rectangle areas were judged about as accurately as circle areas. A surprise was that comparing two squares produced the worst accuracy among the aspect ratio combinations tested.
Nicholas Kong, Jeffrey Heer and Maneesh Agrawala compared treemaps with hierarchical bar charts as the number of items grew. When comparing two leaf items, bar charts were more accurate at lower densities; treemaps matched them past about 4,096 leaves and were faster there. When comparisons involved parent nodes, treemaps were more accurate. Their guidance, in plain words: with only a few hundred elements, bars are more effective for leaf values; with thousands, treemaps are. The stimuli were 600 × 400 pixel images, so treat the thresholds as tied to that size.
For a web report with 21 sources, that points clearly to bars for comparing sources. The treemap's case here rests on showing the channel structure.
How is a squarified treemap laid out?
The first treemaps used slice-and-dice: split the box into strips, switching direction at each level. Applied to our seven channels in an 8 × 5 box (one unit of area is 1,000 sessions), the AI assistants strip would be 0.12 wide and 5 tall, about 42 times longer than wide. The squarified algorithm by Bruls, Huizing and van Wijk avoids this in four moves:
- Sort the values from largest to smallest and work along the shorter side of the free space.
- Add the next rectangle to the current row if the worst aspect ratio in the row gets better. Organic search alone, 3.2 × 5, has a ratio of 1.56.
- If adding would make it worse, freeze the row. Putting Direct under Organic search would push the worst ratio to 2.84, so Organic search is fixed and Direct starts a new row in the remaining 4.8 × 5 space. Direct alone scores 2.74; adding Referral improves it to 1.54; adding Social would worsen it to 3.13.
- Repeat in the leftover space until all items are placed. In this sample the other rows are Social alone, Email alone, Paid alone and AI assistants in the last 1.2 × 0.5 corner.
The worst rectangle ends at 2.4, against about 42 with slice-and-dice. The cost, noted in the Maryland history, is that squarified layouts lose the original order and can shift noticeably when values change.
How do you read a treemap without being misled?
| Check | What to do |
|---|---|
| What does area encode? | Read the title; area must be one additive value |
| What does color encode? | Often a second measure, such as conversion rate; check the legend, and do not read color as size |
| Are the small items grouped? | An "Other" box hides detail; ask what it contains |
| Is depth readable? | More than two levels at once usually needs click-to-zoom |
| Two periods side by side? | Positions may move, so compare labels and numbers, not places |
| Do the parts sum to the total shown? | Add them; missing or unassigned traffic should have its own box |
One more rule for publishing: print the value in each labelled box and offer the underlying table, so readers who cannot judge area, including screen reader users, still get the numbers.
What can you use instead?
- Sorted bar chart grouped by parent: for up to a few dozen items; the default for web reports.
- Two bar charts: channel totals on top, sources of the selected channel below; exact and still hierarchical.
- 100% stacked bars: to compare the channel mix of several periods or segments.
- Scatter plot: when you care about two measures at once, such as volume and conversion; see scatter plots.
- Table with a small inline bar: for audits where each number matters.
For the wider vocabulary of encodings, see data visualization.
How to get this data from TapCub
TapCub does not draw treemaps. It gives you the grouped numbers, and for the 21-source case above its sorted tables are the better view anyway.

- Open Web analytics › Sources. The Channel groups tab shows sessions, share, visitors, engaged rate, bounce rate and conversion rate per channel type; Referrers and UTM give the level below.
- Answer the ranking question there. On Channel groups, sort by sessions, read the share column, then the conversion rate next to it to see whether a big channel is also a good one.
- See the mix over time. Channel mix over time shows counts or shares, which a treemap cannot do.
- Export if you need a treemap. Table export offers CSV and XLSX; keep a column for channel, one for source and one for sessions, and draw it in your charting tool. Check that exported rows add up to the total before you publish.
FAQ
What is a treemap used for?
Showing how a total splits across a hierarchy, such as storage by folder or traffic by channel and source. Each rectangle's area stands for a value, and nesting shows the grouping. It is most useful when there are many items and group totals matter more than precise comparisons between two small ones.
Is a treemap better than a pie chart?
For many categories or two levels, usually yes, because rectangles pack and label more easily than thin slices. Both encode quantity in ways that are harder to judge than bar length. With a handful of categories, a sorted bar chart is clearer than either.
How many categories can a treemap show?
Technically thousands, which is where research found treemaps competitive with bar charts. Readability depends on size: a source with 0.5% of an 800 by 500 pixel chart gets a square about 45 pixels wide. Group the tail into "Other" and keep the detail in a table.
What does color mean in a treemap?
Whatever the legend says. It may mark the parent group, or encode a second measure such as growth or conversion rate. Use one meaning at a time, keep the scale readable for color-blind viewers and never let color be the only way to read an important value.
Can a treemap show negative values?
No, because area cannot be negative. For profit and loss, or change that can go either way, use a diverging bar chart. Some tools size rectangles by absolute value and color by sign, which readers easily misread, so label it clearly if you must.
Sources
- Treemaps for space-constrained visualization of hierarchies: history (University of Maryland HCIL)
- Bruls, Huizing and van Wijk, Squarified Treemaps (2000)
- Heer and Bostock, Crowdsourcing Graphical Perception (CHI 2010)
- Kong, Heer and Agrawala, Perceptual Guidelines for Creating Rectangular Treemaps (authors' copy, 2010)
Was this article helpful?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Product Experience Specialist
Explores usability, user journeys, and feature adoption through practical examples of onboarding and everyday product use.



