Statistics Kingdom

Treemap

Free treemap maker: paste a table of groups, names and values, pick a flat or a 3D treemap and a style, then download it as a PNG or SVG. No sign-up. All chart types →

Pick a treemap, flat (2D) or with depth (3D). You can change it later — your data stays.

How to make a treemap

  1. Chart type: pick a flat (2D) treemap, with a line or a name band round each group, or a 3D treemap of raised blocks.
  2. Data: type or paste your table: the group in the first column (optional), the name in the second, the value in the third, and a number for the color in the fourth (optional). Or open an Excel or CSV file.
  3. Design & download: pick how to color the boxes, a style and the labels, then download a PNG or SVG, get the R code, or save the treemap in a .tmap file to keep editing later.

What is a treemap?

A treemap shows the parts of a whole as boxes. Each box is as big as its value: a part that is twice as big gets a box with twice the area. The boxes of one group sit together inside one bigger box, so you see the size of each group and of each part in it at once. The boxes are laid out "squarified": as close to squares as they can be, the biggest at the top left.

Example 1 is a family’s monthly budget: rent is one box of the Home group, and it is almost a third of the picture. Example 2 is the space used on a computer disk, by folder, with each box labelled in % of the whole. Example 3 is a shop’s sales: the size of a box is the sales, its color the change from last year, red below 0 and green above (all three are invented example data).

How to lay out the data

  • Group (first column, optional): the boxes with the same group sit together. Leave it empty for a treemap with one level.
  • Name (second column): the words in the box.
  • Value (third column): the size of the box, a number above 0. A word, 0 or a negative number is left out, and a note says so.
  • Color (fourth column, optional): a number that sets the box’s color when Color by is Color column, for example a change in %.

One row is one box. The values are added up for each group, so the group’s box is as big as all its boxes together. Paste the table straight from Excel or Google Sheets, or open an Excel or CSV file.

How to read a treemap

Compare areas, not lengths: the biggest box is the biggest part. Read the groups first (their color, or their line or name band), then the boxes inside each group. The percent labels (Name and % of total) say exactly how big each part is.

  • A treemap is good for many parts, and for parts inside groups: a budget, a disk, the sales of many products, a stock market by sector.
  • A pie chart reads better for a few parts (up to about 6) of one whole. Try the pie chart maker.
  • A bar chart is better when the exact order and small differences matter: lengths are easier to compare than areas. Try the bar chart maker.

How to make a treemap in Excel

Excel has a treemap chart in Excel for Microsoft 365, Excel 2024 and Excel 2021 (on Windows and Mac):

  1. Select your data: the group, the name and the value columns.
  2. Go to the Insert tab > Insert Hierarchy Chart > Treemap (on a Mac: Insert > Hierarchy > Treemap). Insert > Recommended Charts > All Charts has it too.
  3. To change the labels: right-click a box > Format Data Series > Series Options > Label Options. The Chart Design and Format tabs change the look.

Excel gives each top-level group its own color. For 3D blocks, a color column, a header band or R code, paste the same table into this page.

How to make a treemap in R

The treemap package draws treemaps in R. The R code button under the chart writes the code for your own table and settings; this is the code of Example 1. With algorithm = "squarified", sortID = "-size" and mirror.y = TRUE, R lays out the boxes the same way as this page, and aspRatio gives the treemap the same shape, so R draws the same boxes in the same places.

# Treemap with the treemap package (install it once: install.packages("treemap"))
library(treemap)

# One row for each box: its group, the words in it, its value (the size of the box) and its color
df <- data.frame(
  group = c("Home", "Home", "Home", "Home", "Food", "Food", "Food", "Transport", "Transport",
            "Transport", "Health", "Health", "Fun", "Fun", "Fun", "Savings"),
  label = c("Rent\n$1,200", "Power\n$150", "Water\n$60", "Internet\n$50", "Groceries\n$520",
            "Eating out\n$210", "Coffee\n$45", "Car payment\n$300", "Fuel\n$180",
            "Bus pass\n$60", "Insurance\n$240", "Gym\n$40", "Holidays\n$200",
            "Hobbies\n$90", "Streaming\n$35", "Savings\n$400"),
  value = c(1200, 150, 60, 50, 520, 210, 45, 300, 180, 60, 240, 40, 200, 90, 35, 400),
  fill  = c("#ea1728", "#ed3a48", "#f05d69", "#f37f89", "#89e101", "#a4e83a", "#beef73", "#02bbe9",
            "#3bcaee", "#74daf3", "#f3a014", "#f8cb7e", "#8e44ad", "#a76ebf", "#c198d2",
            "#ff4f9a"),
  stringsAsFactors = FALSE
)

tm <- treemap(df,
  index = c("group", "label"),   # the groups, then the boxes in each group
  vSize = "value",                # the area of each box
  type = "color", vColor = "fill",   # each box gets its color from the fill column
  algorithm = "squarified",       # the layout of this page
  sortID = "-size",               # the biggest box first
  mirror.y = TRUE,                # ... at the top left
  aspRatio = 1.35,               # the shape of the treemap on this page (width / height)
  title = "A family\u2019s monthly budget (example data)",
  fontsize.labels = c(14, 11),
  align.labels = list(c("left", "top"), c("center", "center")),
  border.col = "white", border.lwds = c(4, 1)
)

# tm$tm holds each box's place: x0, y0, w, h (from 0 to 1, y up).
# The styles, the gaps and the look of the labels are this page's;
# R writes the group names and the labels its own way.

2D or 3D treemap?

A flat (2D) treemap is the one to read: every box shows its full area, and the words fit inside. Use it for reports and papers. 2D with group headers writes each group’s name on a band above its boxes.

A 3D treemap raises each box into a block. 3D tiles (the same height) look good on slides; the groups stand on a low base. 3D height by value shows each value twice, by the area and by the height, so the big parts stand out; but a tall block can hide a small one behind it, so keep a 2D copy for the exact reading.

Frequently asked questions

Is this treemap maker free? Do I need an account?

It is free, and there is no sign-up or login. The small statskingdom.com mark in the corner of the chart can be removed, or changed to your own name, in the Watermark box.

Can a treemap show negative numbers or zero?

Not as a box: the area of a box cannot be 0 or less, so a row with a value of 0 or below is left out and a note under the chart says so. To show losses or changes, keep a positive size in the Value column (for example sales) and put the change in the Color column, as Example 3 does.

Do I need groups?

No. Leave the Group column empty and you get a treemap with one level: one box for each row. With groups, each group gets its own color (Color by Group) and its boxes sit together.

How many boxes can a treemap have?

Up to 500 rows. With more, the first 500 are drawn and a note says so. A box too small for its words shows only its name, or nothing (a note says so): make the chart bigger, or choose Text size Small.

What is the Color column for?

A second number for each box, shown by its color while the size shows the value. Choose Color by: Color column, a two-sided scale such as Red–Yellow–Green, and Range: Middle at 0, so that falls are red and rises are green.

Can I save my treemap and keep editing it later?

Yes. Save, under the chart, puts your table and all your settings into a .tmap file on your computer; Open brings it back here. Nothing is uploaded. This browser also keeps your last treemap: the Last run button in step 2 brings it back.

What can I download?

A PNG picture (twice the size of the chart on the screen), an SVG file that stays sharp at any size and opens in Word, PowerPoint and Inkscape, Copy, which puts the picture on the clipboard, and the R code that draws the same treemap.

Treemap made with this treemap maker: a family's monthly budget, one box for each cost, as big as its value, each group in its own color
Made with this page: Example 1 as a 2D treemap in the Plastic style, with a line round each group.