Learn R Programming

treemapify (version 2.3.1)

geom_treemap_text: Add text labels to treemap tiles.

Description

This will draw a text label for each tile in a treemap created by geom_treemap. In addition to the required <U+2018>label<U+2019> aesthetic, it requires an <U+2018>area<U+2019> aesthetic as used in geom_treemap; if this is mapped to a different column, or geom_treemap and geom_treemap_text are passed different data, the text labels probably won't line up with the tiles.

geom_treemap_text uses geom_fit_text from the ggfittext package to fit text to the tile. All text drawing options available in ggfittext (growing, reflowing, etc.) are also available here. For full details see the documentation for ggfittext::geom_fit_text.

Usage

geom_treemap_text(mapping = NULL, data = NULL, stat = "identity",
  position = "identity", na.rm = FALSE, show.legend = FALSE,
  inherit.aes = TRUE, padding.x = unit(1, "mm"), padding.y = unit(1,
  "mm"), place = "topleft", min.size = 4, grow = F, reflow = F,
  fixed = F, ...)

Arguments

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

Standard geom arguments as for geom_rect.

padding.x, padding, y

Unit object, giving horizontal or vertical padding between text and edge of tile. Defaults to 1 mm.

place

Where should the text be drawn within the tile? One of <U+2018>topleft<U+2019>, <U+2018>top<U+2019>, <U+2018>topright<U+2019> etc. Defaults to <U+2018>topleft<U+2019>.

min.size

Number, in points. Text that would need to be drawn smaller than this size to fit in the tile will be hidden. Defaults to 4 pt.

grow

Logical; should text grow to fill the entire tile? Defaults to false.

reflow

Logical; should text should be reflowed (wrapped) to better fit the bounding box? Defaults to false.

fixed

Logical, indicating whether the fixed layout algorithm should be used. Defaults to false. See geom_treemap for full details.

Aesthetics

  • area (required)

  • label (required)

  • colour

  • size

  • alpha

  • family

  • fontface

  • angle

See Also

geom_treemap, geom_fit_text