Skip to main content

12  Pie charts

library(rtemis.draw)

draw_pie() draws the share of each label in a total, as a pie, a donut, or a Nightingale rose.

12.1 Basic

species_counts <- table(penguins$species)
draw_pie(as.integer(species_counts), names(species_counts))

12.2 Nightingale / Rose Chart

Set rose_type = "radius" to show each value as the slice’s radius as well as its angle; rose_type = "area" gives every slice the same angle:

draw_pie(
  as.integer(species_counts),
  names(species_counts),
  rose_type = "radius"
)

12.3 Donut

A two-element radius sets the inner and the outer radius. label_format sets each slice label to the name, the value, the percentage, or the name with either; values that share a label sum into one slice:

draw_pie(
  penguins$body_mass[!is.na(penguins$body_mass)],
  penguins$species[!is.na(penguins$body_mass)],
  radius = c("40%", "75%"),
  label_format = "name_percent"
)

12.4 Configuration

setup_PieConfig() describes a pie chart by its label and value columns:

counts <- as.data.frame(table(species = penguins$species), responseName = "n")
config <- setup_PieConfig(values = "n", labels = "species", inner_radius = "40%")
draw(config, data = counts)
© 2026 E.D. Gennatas