Learn R Programming

treemapify (version 2.3.1)

geom_treemap: A treemap

Description

Draw a treemap, where each observation is represented by a tile scaled by an area aesthetic.

<U+2018>area<U+2019> is the only required aesthetic. Other aesthetics are accepted as for geom_rect. See geom_treemap_text to label tiles.

An optional <U+2018>subgroup<U+2019> aesthetic will cause the tiles to be clustered in subgroups within the treemap. See geom_treemap_subgroup_border and geom_treemap_subgroup_text to draw a border around subgroups and label them respectively.

With the default tile layout algorithm (fixed = F), tile placement proceeds from the bottom left corner, moving alternately rightwards and upwards until all tiles are placed. See Bruls et al. (1999) for the full algorithm.

With the fixed tile layout algorithm (fixed = T), tile placement fills columns from left to right, beginning at the bottom of each column. However, unlike with the default algorithm, the order in which tiles are placed is fixed by their order in the input data frame. While this can result in some aesthetically unpleasing tiles, it allows side-by-side comparisons or animations to be created. If the fixed algorithm is used for geom_treemap, it should also be used for all other treemap geoms in the plot or they will not share a common layout.

Usage

geom_treemap(mapping = NULL, data = NULL, stat = "identity",
  position = "identity", na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, fixed = F, ...)

Arguments

mapping, data, stat, position, na.rm, show.legend, inherit.aes, ...

Standard geom arguments as for geom_rect.

fixed

Logical, indicating whether the fixed layout algorithm should be used. Defaults to false.

Aesthetics

  • area (required)

  • alpha

  • colour

  • fill

  • linetype

  • subgroup

References

The default tile layout uses the Squarified Treemap algorithm of Mark Bruls, Kees Huizing and Jarke van Wijk:

Bruls, M., Huizing, K., & van Wijk, J. (1999). Squarified Treemaps (pp. 33-42). Presented at the In Proceedings of the Joint Eurographics and IEEE TCVG Symposium on Visualization. http://www.win.tue.nl/~vanwijk/stm.pdf

See Also

geom_treemap_text, geom_treemap_subgroup_border, geom_treemap_subgroup_text