Treemap Visualization

A treemap is a space-filling visualization of hierarchical structures. This package offers great flexibility to draw treemaps.


version 2.4-2

  • added format.legend argument to control legend number formatting
  • fixed data.table warning

version 2.4-1

  • fixed bug related to sortID
  • updated GNI data

version 2.4

  • added mapping argument to support manual palette mappings (see new vignette)
  • added standard error aggregations
  • added draw argument to prevent drawing
  • aggregation function can be specified (e.g. weighted.mean)
  • compatible with tbl_df and tbl_dt

version 2.3

  • added argument n, number of categories
  • added mirror.x and .y
  • fixed treegraph bug (changed vertex.layout argument)
  • dplyr objects work with treemap
  • fixed bug in comparison treemap with specified range
  • fixed treecolors and itreemap warning messages

version 2.2

  • added treecolors, a function to experiment with Tree Colors
  • improved treegraph: added layout options
  • added

version 2.1-1

  • minor fix: for compatibility with R<3.0.0, rep_len is replaced by rep(..., length.out=)

version 2.1

  • itreemap added, a web-interface (made with shiny) added
  • treepalettes added, to make hierarchical color palettes directly available
  • treegraph added, to draw a radial tree with colors from treepalettes
  • hierarchical color palettes method slightly improved (brighter)
  • border line thickness (border.lwds) added as parameter to adjust line thickness at variaous agggregation levels
  • improved text color decision (black or white) given the background color
  • fontfamily parameters added (thanks to Peter Ellis)
  • border.col parameter added (thanks to Peter Ellis)
  • type "value" has evolved into two options: "value", which is now focused on diverging color palettes, and "manual" in which a palette is directly mapped to the provided range.
  • bug in type "comp" fixed
  • bug in quantitative scales fixed
  • enhanced treemap output: added columns colorvalue and color, aspect ratio, and range
  • improved business test data set (removed redundant colums)
  • add version number of required data.table package to prevent conflicts

version 2.0-1

  • computation time examples shorter (CRAN policy)

version 2.0

  • main function migrated to treemap
  • treemap types revised: two new types added: "color", by which users are able to provide custom colors to each rectangle, and "index" (which different from the "index" in prior versions which is now renamed to "depth"). The new "index" type hierarchically assigns a color for each category in the index-tree (defined by the index variables). Treemap type "linked" removed, since it is obsolete by "categorical" type in combination of argument vp (see below).
  • color palette "HCL" added, which picks colors from the HCL color space. Applicable for "index", "depth" and "categorical". Additional arguments added to fully control color picking method.
  • vp argument added, to place treemap inside a grid.viewport. Useful for custom made visualizations or small multiples.
  • small multiples not directly facilitated anymore, since it can easily be done with the vp argument.
  • invisible treemap output redefined
  • aggregation method (under the engine) re-implemented
  • businness statistics example dataset replaced. The new dataset contains four hierarchical levels.
  • bug in value-type color assignment fixed
  • color palette mapping improved
  • label overlapping improved: added overlap.labels argument
  • fixed bug in color scaling number

version 1.1-2

  • no dependencies anymore, only imports

version 1.1-1

  • improved value treemap (better color range)
  • added new example dataset: GNI2010
  • fixed bug with character variables as index variables
  • fixed bug with non-factor variables as categorical variable

version 1.1

  • added categorical treemap type (each category has own color)
  • added position.legend argument, which determines whether legend is placed: "bottom", "right", or "none"

version 1.0-4

  • two bugs fixed (category labels were not shown, and sorting order was sometimes neglected)
  • aspect ratio control added (argument aspRatio)

version 1.0-3

  • faster aggregation (using data.table instead of plyr)
  • treemap types rearranged: also added type "index"
  • second layout algorithm implemented: squarified treemaps
  • more possibilities added to tweak font sizes
  • argument na.rm added in case there are missing values during aggregation

version 0.11-1

  • updated examples of tmPlot

version 0.11

  • added treemap type "value", which means that values of the color variable are directly mapped to the color palette. This type is mostly used for the Map of the Market kind of treemaps, with negative values colored red, zeros yellow, and positive values green.
  • added the possibility to use own palettes
  • added parameters to tweak the font sizes
  • cleaned up the code

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.4-2 by Martijn Tennekes, 3 years ago

Browse source code at

Authors: Martijn Tennekes [aut, cre] , Peter Ellis [ctb]

Documentation:   PDF Manual  

Task views: Official Statistics & Survey Methodology

GPL-3 license

Imports colorspace, data.table, ggplot2, grid, gridBase, igraph, methods, RColorBrewer, shiny

Suggests knitr

Imported by bdvis, colorfindr, immunarch, ipADMIXTURE, lar.

Suggested by data.tree.

Enhanced by d3r, sunburstR.

See at CRAN