I'm working on a scatterplot using geom_jitter but want to set limits on the y axis (min value = 0). Is there a way to allow the points to "jitter" per usual but to tell them not to drop below y=0?
Don't censor
the out of bounds (oob
) points (which is the default), but instead squish
to your scale, like so:
test <- data.frame(x = mtcars$mpg, y = 0)
ggplot(test, aes(x, y)) +
geom_jitter() +
scale_y_continuous(limits = c(0, 0.4), oob = scales::squish)