我制作了一个山脊线图,但我想为其添加自定义标记(弹出我添加的代表)。我能想到的最好的方法是添加标签。这并不理想。
我找到了这个链接,这更符合我的要求。但我无法让该示例适用于我的案例(使用 fill = 绘制因子水平)。
下面是一些我能想到的最好的输出。
谢谢。
library(tidyverse)
library(ggridges)
dfs <-
data.frame(
"estimate" = rnorm(300),
"loading" = factor(rep(1:5, 60)),
"set" = factor(rep(1:3, 100),),
"pop" = rep(c(0.1, 0.15, 0.20, 0.05, 0.7), 60)
)
ggplot(dfs, aes(x = estimate, y = loading, fill = set)) +
geom_density_ridges(
jittered_points = TRUE,
point_shape = "|", point_size = 2, size = 0.25,
position = position_points_jitter(height = 0), alpha = 0.6, scale = 1.2)
#> Picking joint bandwidth of 0.395
loadsummary2 <- crossing("set" = dfs$set, "loading" = dfs$loading)
loadsummary2$pop <- rep(c(0.1, 0.15, 0.20, 0.05, 0.7), 3)
ggplot(dfs, aes(x = estimate, y = loading, fill = set)) +
geom_density_ridges(
jittered_points = TRUE,
point_shape = "|", point_size = 2, size = 0.25,
position = position_points_jitter(height = 0), alpha = 0.6, scale = 1.2) +
geom_label(data = loadsummary2, aes(y = loading, x = pop), label = "*")
#> Picking joint bandwidth of 0.395
由reprex 包(v0.3.0)于 2020 年 3 月 13 日创建