标注扇区或圆心

函数索引 / 饼图与环形图
geom_pie_label()
对扇区显示比例,也能在环形图的圆心标示总量。与扇区图层共用统计计算。
怎么用
为两个图层传入相同的类别、圆心、半径及角度设置。可用回调为每个圆心生成一条文字。
返回结果
返回 ggplot2 图层。圆心行提供位置、总量及其显示文字,扇区行还包括比例和角度。
调用方式
geom_pie_label(
mapping = NULL,
data = NULL,
...,
placement = c("inside", "outside", "center"),
label = NULL,
label_format = c("plain", "markdown", "formula"),
min_fraction = 0,
label_radius = NULL,
check_overlap = FALSE,
x0 = 0,
y0 = 0,
r = 1,
r0 = 0,
start = 0,
direction = 1,
order = "levels",
explode = 0,
gap = 0,
lang = NULL,
dictionary = NULL,
variable = "slice",
text_direction = "auto",
show.legend = FALSE,
inherit.aes = TRUE,
na.rm = FALSE
)参数
mapping、data、...、placement、label、label_format、min_fraction、label_radius、check_overlap、x0, y0、r, r0、start、direction、order、explode、gap、lang、dictionary、variable、text_direction、show.legend, inherit.aes、na.rm
R 示例
d <- data.frame(site = c(1, 1, 4, 4), mode = c("A", "B", "A", "B"),
n = c(9, 11, 12, 8))
ggplot2::ggplot(d, ggplot2::aes(x0 = site, slice = mode, fill = mode, weight = n)) +
geom_pie(r0 = 0.5) + geom_pie_label(placement = "center", r0 = 0.5) +
ggplot2::coord_fixed()