ggplot_donut | R Documentation |
Create a donut plot from a data frame containing groups and corresponding values with
ggplot2::ggplot()
.
ggplot_donut(data, group = "group", value = "n", hsize = 2)
data |
Default dataset to use for plot. If not already a data.frame,
will be converted to one by |
group |
Name of column to use for the plot colors. |
value |
Name of column to use for the sector size. |
hsize |
Size of the donut hole. Defaults to |
Implemented using ggplot2::geom_col()
, ggplot2::coord_polar()
, and ggplot2::xlim()
, adapted
from guides in The R Graph Gallery
and R CHARTS.
Some default plot elements are disabled using ggplot2::theme()
and ggplot2::element_blank()
.
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)
mtcars |>
count(cyl) |>
mutate(cyl = as.factor(cyl)) |>
ggplot_donut(group = "cyl")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.