Create nested pie plot.

ggnestedpie(
  data,
  group_key = NULL,
  count_type = c("count", "full"),
  r0 = 0.5,
  r1 = 1.5,
  r2 = 2.5,
  inner_thick = 1,
  outer_thick = 1,
  inner_fill_color = NULL,
  inner_label = TRUE,
  inner_label_info = c("count", "ratio", "all"),
  inner_label_color = "black",
  inner_label_split = "[[:space:]]+",
  inner_label_len = 40,
  inner_label_threshold = NULL,
  inner_label_size = 4,
  outer_fill_color = NULL,
  outer_label_type = c("circle", "horizon", "none"),
  outer_label_pos = c("in", "out"),
  outer_label_info = c("count", "ratio", "all"),
  outer_label_split = "[[:space:]]+",
  outer_label_len = 40,
  outer_label_color = "black",
  outer_label_gap = 0.05,
  outer_label_threshold = NULL,
  outer_label_size = 4,
  border_color = "black",
  border_size = 1,
  outer_nudge_x = 1,
  outer_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.

r0

The radius of inner blank circle. Default: 0.5 (donut plot). When set to 0, inner plot is pie.

r1

The radius of inner pie plot. Default: 1.5.

r2

The radius of outer pie plot. Default: 2.5.

inner_thick

The width of inner pie plot. Default: 1.

outer_thick

The width of outer pie plot. Default: 1.

inner_fill_color

Colors used for inner pie plot. Default: NULL (conduct automatic selection).

inner_label

Logical value, whether to show label on inner pie label. Default: TRUE.

inner_label_info

Label information type of inner pie plot, chosen from count, ratio and all (count and ratio). Default: count.

inner_label_color

Color of the label on inner pie. Default: black.

inner_label_split

Pattern used to split the label of inner pie, support regular expression. Default: space.

inner_label_len

Label text length of inner pie. Used when inner_label_split is NULL. Default: 40.

inner_label_threshold

Threshold of the ratio to determine label or not on inner pie. Default: NULL.

inner_label_size

Size of the label on inner pie. Default: 4.

outer_fill_color

Colors used for outer pie plot. Default: NULL (conduct automatic selection).

outer_label_type

Label style of outer pie plot, chosen from circle, horizon and none (no label). Default: circle.

outer_label_pos

Label position of outer pie, chosen from in and out. Default: in.

outer_label_info

Label information type of outer pie plot, chosen from count, ratio and all (count and ratio). Default: count.

outer_label_split

Pattern used to split the label of outer pie, support regular expression. Default: space.

outer_label_len

Label text length of outer pie. Used when outer_label_split is NULL. Default: 40.

outer_label_color

Color of the label on outer pie. Default: black.

outer_label_gap

Gap between label and outer pie plot, used when outer_label_pos is out.

outer_label_threshold

Threshold of the ratio to determine label position (in/out pie). Default: NULL.

outer_label_size

Size of the label on outer pie. Default: 4.

border_color

Border color. Default: black.

border_size

Border thickness. Default: 1.

outer_nudge_x

Parameter of geom_text_repel. Default: 1.

outer_nudge_y

Parameter of geom_text_repel. Default: 1.

Value

A ggplot2 object.

Examples

library(ggpie) library(ggplot2) data(diamonds) # inner circle label, outer circle label and in pie plot ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", inner_label_info = "all", inner_label_split = NULL, outer_label_type = "circle", outer_label_pos = "in", outer_label_info = "all" )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# inner circle label, outer circle label and in pie plot, remove fraction below 1 of inner pie ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", inner_label_info = "all", inner_label_split = NULL, inner_label_threshold = 1, inner_label_size = 3, outer_label_type = "circle", outer_label_pos = "in", outer_label_info = "all" )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# inner circle label, outer circle label and out of pie plot ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", inner_label_info = "all", inner_label_split = NULL, outer_label_type = "circle", outer_label_pos = "out", outer_label_info = "all" )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# inner circle label and no split, outer horizon label and out of pie plot, # remove fraction below 1 of inner pie ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", inner_label_info = "all", inner_label_split = NULL, inner_label_threshold = 1, inner_label_size = 3, outer_label_type = "horizon", outer_label_pos = "out", outer_label_info = "all" )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# inner circle label and no split, outer horizon label and in pie plot, # remove fraction below 1 of inner pie, # adjust fraction below 10 to out of pie of outer pie plot. ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", inner_label_info = "all", inner_label_split = NULL, inner_label_threshold = 1, inner_label_size = 3, outer_label_type = "horizon", outer_label_pos = "in", outer_label_info = "all", outer_label_threshold = 10 )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# create blank between inner and outer pie ggnestedpie( data = diamonds, group_key = c("cut", "color"), count_type = "full", r0 = 0.5, r1 = 1.5, r2 = 2.6, inner_label_info = "all", inner_label_split = NULL, inner_label_threshold = 1, inner_label_size = 3, outer_label_type = "horizon", outer_label_pos = "in", outer_label_info = "all", outer_label_threshold = 10 )
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.