[英]Aligning geom_text to geom_jitter points
How can I align (along the x axis dimension) the text labels with the jittered points in the following plot in R ggplot2
? 如何将(沿x轴维度)文本标签与R ggplot2
下图中的抖动点ggplot2
?
library(dplyr)
library(ggplot2)
mtcars %>%
ggplot(aes(am, wt, group = am, label = wt)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter() +
geom_text()
Easy solution would be to specify position_jitter
in both geom_text
and geom_jitter
with the same seed
. 简单的解决方案是使用相同的seed
在geom_text
和geom_jitter
指定position_jitter
。
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.