Keep points above zero in geom_jitter

廉价感情. 提交于 2020-01-03 05:17:11

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/48032561/keep-points-above-zero-in-geom-jitter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!