diff --git a/R/position-nudge.R b/R/position-nudge.R index 6bf8a81f01..cd28360d79 100644 --- a/R/position-nudge.R +++ b/R/position-nudge.R @@ -27,6 +27,11 @@ #' 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))) position_nudge <- function(x = NULL, y = NULL) { ggproto(NULL, PositionNudge, x = x, diff --git a/man/position_nudge.Rd b/man/position_nudge.Rd index 0db66c8035..89b5a14326 100644 --- a/man/position_nudge.Rd +++ b/man/position_nudge.Rd @@ -43,6 +43,11 @@ ggplot(df, aes(x, y)) + 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))) } \seealso{ Other position adjustments: