df <- data.frame(
x = c(1,3,2,5),
y = c("a","c","d","c")
)
ggplot(df, aes(x, y)) +
geom_point() +
geom_text(aes(label = y))
ggplot(df, aes(x, y)) +
geom_point() +
geom_text(aes(label = y), position = position_nudge(y = -0.1))
# Or, in brief
ggplot(df, aes(x, y)) +
geom_point() +
geom_text(aes(label = y), nudge_y = -0.1)
# For each text individually
ggplot(df, aes(x, y)) +
geom_point() +
geom_text(aes(label = y, nudge_y = c(-0.1, 0.1, -0.1, 0.1)))
Run the code above in your browser using DataLab