ggdonut {ggpie} | R Documentation |
Create donut plot.
Description
Create donut plot.
Usage
ggdonut(
data,
group_key = NULL,
count_type = c("count", "full"),
fill_color = NULL,
label_info = c("count", "ratio", "all"),
label_split = "[[:space:]]+",
label_len = 40,
label_color = "black",
label_type = c("circle", "horizon", "none"),
label_pos = c("in", "out"),
label_gap = 0.05,
label_threshold = NULL,
label_size = 4,
border_color = "black",
border_size = 1,
r0 = 1,
r1 = 3,
donut.label = TRUE,
donut.label.size = 4,
donut.label.color = "red",
nudge_x = 1,
nudge_y = 1
)
Arguments
data |
Data frame contains full data or summarized data. |
group_key |
Column used to summarize the data. Default: NULL. |
count_type |
Data frame type, chosen from "count" and "full". "count" means summarized data and "full" means full data. Default: count. |
fill_color |
Colors used. Default: NULL (conduct automatic selection). |
label_info |
Label information type, chosen from count, ratio and all (count and ratio). Default: count. |
label_split |
Pattern used to split the label, support regular expression. Default: space. |
label_len |
The length of label text. Used when |
label_color |
Color of the label. Default: black. |
label_type |
Label style, chosen from circle, horizon and none (no label). Default: circle. |
label_pos |
Label position, chosen from in and out. Default: in. |
label_gap |
Gap between label and pie plot, used when |
label_threshold |
Threshold of the ratio to determine label position (in/out pie). Default: NULL. |
label_size |
Size of the label. Default: 4. |
border_color |
Border color. Default: black. |
border_size |
Border thickness. Default: 1. |
r0 |
The radius of inner blank circle. Default: 1. |
r1 |
The radius of outer circle. Default: 3. |
donut.label |
Logical value, whether to show total number in the center of the plot. Default: TRUE. |
donut.label.size |
The label size of center label. Default: 4. |
donut.label.color |
The color of center label. Default: red. |
nudge_x |
Parameter of |
nudge_y |
Parameter of |
Value
A ggplot2 object.
Examples
library(ggpie)
library(ggplot2)
data(diamonds)
# circle label and out of pie
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "circle",
label_size = 4, label_pos = "out"
)
# circle label and in pie plot, with no split
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "circle", label_split = NULL,
label_size = 4, label_pos = "in"
)
# horizon label and in pie plot, with no split
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon", label_split = NULL,
label_size = 4, label_pos = "in"
)
# horizon label and in pie plot
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon",
label_size = 4, label_pos = "in"
)
# horizon label and out of pie plot, with no split
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon", label_split = NULL,
label_size = 4, label_pos = "out"
)
# horizon label and out of pie plot
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon",
label_size = 4, label_pos = "out"
)
# with label threshold
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon", label_split = NULL,
label_size = 4, label_pos = "in", label_threshold = 10
)
ggdonut(
data = diamonds, group_key = "cut", count_type = "full",
label_info = "all", label_type = "horizon",
label_size = 4, label_pos = "in", label_threshold = 10
)