In R ggplot2, when I plot all zeros and use geom_jitter(), some variations are automatically added to zeros. How can I undo that? I still want all points at 0 y axis.
y = rep(0,100)
x = rep(c("A","B","C","D"),25)
D = data.frame(x,y)
library(ggplot2)
ggplot(D,aes(x=x,y=y))+geom_boxplot() + geom_jitter()
If you need to keep the dots and spread them horizontally, you can use geom_jitter(height = 0)
. This will force the vertical variation/jitter to zero, but still allows the points to "jitter" horizontally.
ggplot(D, aes(x = x, y = y)) +
geom_boxplot() +
geom_jitter(height = 0)