ggpie: Create Pie plot.

View source: R/ggpie.R

ggpieR Documentation

Create Pie plot.

Description

Create Pie plot.

Usage

ggpie(
  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,
  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_split is NULL. Default: 40.

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_pos is out.

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.

nudge_x

Parameter of geom_text_repel. Default: 1.

nudge_y

Parameter of geom_text_repel. Default: 1.

Value

A ggplot2 object.

Examples

library(ggpie)
library(ggplot2)
data(diamonds)
# with no label
ggpie(
  data = diamonds, group_key = "cut", count_type = "full",
  label_info = "all", label_type = "none"
)
# circle label and out of pie
ggpie(
  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
ggpie(
  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
ggpie(
  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, split with space
ggpie(
  data = diamonds, group_key = "cut", count_type = "full",
  label_info = "all", label_type = "horizon",
  label_size = 4, label_pos = "in"
)
# horizon label and out pie plot, with no split
ggpie(
  data = diamonds, group_key = "cut", count_type = "full",
  label_info = "all", label_type = "horizon", label_split = NULL,
  label_size = 4, label_pos = "out"
)
# with label threshold
ggpie(
  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
)

ggpie documentation built on Nov. 16, 2022, 9:06 a.m.