df <- data.frame(
x = c(1,3,2,5,4,2.5),
y = c("abc","cd","d","c","bcd","a")
)
# Plain nudging, same as with ggplot2::position_nudge()
ggplot(df, aes(x, y, label = y)) +
geom_point() +
geom_text_s(hjust = "left", vjust = "bottom",
position = position_nudge_keep(x = 0.2, y = 0.2))
# alternating nudging
ggplot(df, aes(x, y, label = y)) +
geom_point() +
geom_text_s(position = position_nudge_keep(x = c(0.2, -0.2)))
# direct nudging
ggplot(df, aes(x, y, label = y)) +
geom_point() +
geom_text_s(position = position_nudge_keep(x = rep_len(c(0.2, -0.2), 6)))
Run the code above in your browser using DataLab