我正在绘制箱线图和小提琴图,以查看使用ggplot2
. 箱线图的四分位数非常接近。这就是为什么它会导致重叠。
我用过ggrepel::geom_label_repel
,但是没用。如果我删除geom_label_repel
,一些标签会重叠。
这是我的 R 代码和示例数据:
dataset <- data.frame(Age = sample(1:20, 100, replace = T))
ggplot(dataset, aes(x = "", y = Age)) +
geom_violin(position = "dodge", width = 1, fill = "blue") +
geom_boxplot(width=0.1, position = "dodge", fill = "red") +
stat_boxplot(geom = "errorbar", width = 0.1) +
stat_summary(geom = "label", fun.y = quantile, aes(label = ..y..),
position = position_nudge(x = -0.05), size = 3) +
ggrepel::geom_label_repel(aes(label = quantile)) +
ggtitle("") +
xlab("") +
ylab(Age)
除此之外,有没有人熟悉箱线图和小提琴图的组合?情节的左侧是箱线图,右侧是小提琴情节(我不是在问并排情节。只是一个情节)。