How can I align (along the x axis dimension) the text labels with the jittered points in the following plot in R 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
.
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With