Skip to contents

Creates a donut chart – a sunburst restricted to the outermost 1–N depth levels. The centre hole is created by shifting Y coordinates so the innermost displayed ring has ymin > 0.

Usage

donut(
  sb,
  levels = 1,
  fill = NULL,
  colour = "white",
  linewidth = 0.2,
  show_labels = FALSE,
  hole_size = 1,
  ...
)

Arguments

sb

A sunburst_data object from sunburst_data().

levels

Number of depth levels to display (from the outermost inward). 1 = single ring, 2 = two concentric rings.

fill

Fill mapping. Accepts bare names or strings. NULL or "none" for static grey, "auto" for depth mapping, or a column name (bare or quoted).

colour

Border colour for segments. Default "white".

linewidth

Border line width. Default 0.2.

show_labels

Whether to display labels. Default FALSE.

hole_size

Size of the centre hole. Higher = larger hole relative to ring thickness. Default 1.

...

Passed to geom_rect().

Value

A ggplot object with coord_polar() and theme_void().

See also

sunburst() for full sunburst plots, icicle() for rectangular layouts.

Examples

sb <- sunburst_data("((a, b, c), (d, e));")
donut(sb, fill = "name")

donut(sb, levels = 2, fill = "depth")