Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring AsIs objects #5290

Closed
wants to merge 8 commits into from
Closed

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Apr 26, 2023

This PR aims to fix #5142.

Briefly, all scales ignore AsIs objects instead of invoking an identity scale.

Contrary to my expectation, I only had to edit ScalesList methods (and their position equivalents) and no individual scales, so no deep rewrite was needed.
While in #5142 I expressed worry about how position aesthetics would play with this, I've grown to love ignored position aesthetics. No more annotation_custom() or awkward manual transformations if you want to make relative annotations!

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

df <- data.frame(t = seq(0, 2*pi, length.out = 100))

ggplot(mpg) +
  geom_point(aes(displ, hwy)) +
  geom_path(
    data = df, 
    aes(x = I(cos(t) / 2.1 + 0.5), 
        y = I(sin(t) / 2.1 + 0.5),
        colour = I(2))
  ) +
  annotate(
    "text", x = I(0.5), y = I(0.5),
    label = "I'm in the middle",
    colour = 4, size = 10
  )

Created on 2023-04-26 with reprex v2.0.2

@teunbrand teunbrand added feature a feature request or enhancement scales 🐍 API change 😈 labels Jul 9, 2023
@thomasp85
Copy link
Member

As discussed we should investigate if we could instead using the same mechanics as after_scale() for this functionality

@teunbrand
Copy link
Collaborator Author

Closing this in favour of #5477

@teunbrand teunbrand closed this Oct 12, 2023
@teunbrand teunbrand mentioned this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change 😈 feature a feature request or enhancement scales 🐍
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Circumventing scales
2 participants