ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

WIP: Aesthetics for positions

Open teunbrand opened this issue 1 year ago • 5 comments

This PR aims to fix #3026 and fix #5445.

Briefly, it adds the ability for position adjustments to declare their own aesthetics. It is currently only implemented for position_nudge().

On any layer where position = "nudge", one can use nudge_x and nudge_y either as a mapped aesthetic inside aes(), or static aesthetic passed through layer(params).

A few examples:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

df <- data.frame(x = 1:2, y = 1:2, z = c(0.5, 1))

ggplot(df, aes(x, y)) +
  geom_point(position = "nudge", nudge_x = 0.5)


ggplot(df, aes(x, y, nudge_y = z)) +
  geom_point(position = "nudge")

Created on 2024-09-12 with reprex v2.1.1

teunbrand avatar Sep 12 '24 12:09 teunbrand