tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.4k stars 2k forks source link

Reproducible example for `position_jitter()` not working #5875

Open fkohrt opened 2 months ago

fkohrt commented 2 months ago

It seems to me, the last of the examples of position_jitter() does not work as intended. In other words: The following code...

https://github.com/tidyverse/ggplot2/blob/8e63882c3c36259785baac0eed5d51525bc40f70/R/position-jitter.R#L43-L47

...does not seem to simply shift the jittered points:

position_jitter-5

But maybe I misunderstood what the example is supposed to show?

teunbrand commented 2 months ago

Thanks for pointing this out. The position adjustment should be constructed as follows jitter <- position_jitter(width = 0.1, height = 0.1, seed = 0) and then it does what it should. The example should be updated to reflect this.