jitter <- position_jitter(width = 0.2, height = 2, seed = 123)
jitter_nudge <- position_jitternudge(width = 0.2, height = 2,
seed = 123, x = 0.1,
direction = "split",
nudge.from = "jittered")
ggplot(mpg[1:20, ],
aes(cyl, hwy, label = drv)) +
geom_point(position = jitter) +
geom_text_s(position = jitter_nudge)
jitter_nudge <- position_jitternudge(width = 0.2, height = 2,
seed = 123, x = 0.35,
direction = "split",
nudge.from = "original.x")
ggplot(mpg[1:20, ],
aes(cyl, hwy, label = drv)) +
geom_point(position = jitter) +
geom_text_s(position = jitter_nudge)
jitter <- position_jitter(width = 0, height = 2, seed = 123)
jitter_nudge <- position_jitternudge(width = 0, height = 2,
seed = 123, x = 0.4,
direction = "split",
nudge.from = "original.x")
ggplot(mpg[1:20, ],
aes(cyl, hwy, label = drv)) +
geom_point(position = jitter) +
geom_text_s(position = jitter_nudge)
jitter_nudge <- position_jitternudge(width = 0, height = 2,
seed = 123, x = 0.4,
direction = "alternate",
nudge.from = "original.x")
ggplot(mpg[1:20, ],
aes(cyl, hwy, label = drv)) +
geom_point(position = jitter) +
geom_text_s(position = jitter_nudge)
# No nudge, show how points have moved with jitter
ggplot(mpg[1:20, ],
aes(cyl, hwy, label = drv)) +
geom_point() +
geom_point_s(position =
position_jitter_keep(width = 0.3, height = 2, seed = 123),
color = "red",
arrow = grid::arrow(length = unit(0.4, "lines")))
Run the code above in your browser using DataLab