在已有图形中添加雷达轮廓

函数索引 / 雷达图
geom_radar() · stat_radar() · geom_radar_label()
给现有 ggplot 添加雷达图的线段、可选填色和数据点。
怎么用
将轴标识与数值映射到图层。同一幅图的网格、轮廓和标签应共用 radar_spec() 生成的设置。
返回结果
返回 ggplot2 图层。stat_radar() 可单独计算图形位置。
调用方式
geom_radar(
mapping = NULL,
data = NULL,
position = "identity",
...,
spec = NULL,
limits = NULL,
missing = c("error", "gap", "omit_group"),
points = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_radar(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
...,
spec = NULL,
limits = NULL,
missing = c("error", "gap", "omit_group"),
label_offset = 0.07,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_radar_label(
mapping = NULL,
data = NULL,
position = "identity",
...,
spec = NULL,
limits = NULL,
missing = c("error", "gap", "omit_group"),
label_offset = 0.07,
na.rm = FALSE,
show.legend = FALSE,
inherit.aes = TRUE
)参数
mapping、data、position、...、spec、limits、missing、points、na.rm、show.legend, inherit.aes、geom、label_offset
R 示例
d <- data.frame(axis = rep(c("Detection", "Lab", "Response"), 2),
score = c(72, 62, 87, 78, 81, 60),
period = rep(c("Before", "After"), each = 3))
spec <- radar_spec(c("Detection", "Lab", "Response"), c(0, 100))
p <- ggplot2::ggplot(d, ggplot2::aes(axis = axis, value = score, group = 1))
p + geom_radar_grid(spec) + geom_radar(spec = spec) +
geom_radar_label(spec = spec) +
ggplot2::facet_wrap(~ period) + ggplot2::coord_fixed()