Skip to contents

Add pie or donut chart

Usage

add_pie(plot, width = 1, reverse = FALSE, ...)

add_donut(plot, width = 1, reverse = FALSE, ...)

Arguments

plot

A tidyplot generated with the function tidyplot().

width

Width of the plot area. Defaults to 50.

reverse

Whether the order should be reversed or not. Defaults to FALSE, meaning not reversed.

...

Arguments passed on to the geom function.

Value

A tidyplot object

Examples

# for a `count` only provide `color`
# `count` of the data points in each `energy_type` category
energy %>%
  tidyplot(color = energy_type) %>%
  add_pie()


energy %>%
  tidyplot(color = energy_type) %>%
  add_donut()


# for a `sum` provide `color` and `y`
# `sum` of `power` in each `energy_type` category
energy %>%
  tidyplot(y = power, color = energy_type) %>%
  add_pie()


energy %>%
  tidyplot(y = power, color = energy_type) %>%
  add_donut()