gpt4 book ai didi

r - 将 geom_text 与 geom_jitter 点对齐

转载 作者:行者123 更新时间:2023-12-03 15:49:38 42 4
gpt4 key购买 nike

如何在 R ggplot2 的下图中将文本标签与抖动点对齐(沿 x 轴维度) ?

library(dplyr)
library(ggplot2)
mtcars %>%
ggplot(aes(am, wt, group = am, label = wt)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter() +
geom_text()

enter image description here

最佳答案

简单的解决方案是指定 position_jitter在两者 geom_textgeom_jitterseed .

library(ggplot2)
ggplot(mtcars, aes(am, wt, group = am, label = wt)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(position = position_jitter(seed = 1)) +
geom_text(position = position_jitter(seed = 1))

enter image description here

关于r - 将 geom_text 与 geom_jitter 点对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52317280/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com