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

<AsIs> never invokes identity scale #5597

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Dec 18, 2023

This PR to the RC branch aims to fix #5596.

Briefly, it early-exits find_scale() when x is an <AsIs> object.

Consequently, no identity scale is added in ScalesList$add_defaults and <AsIs> aesthetics can be combined with regular aesthetics again over different layers. For good measure, the scale_type.AsIs method was removed too.

The reprex from #5596 now gives the same plot regardless of layer order:

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

library(ggplot2)

df <- data.frame(
  x = 1:4, y = 1:4,
  colour = c("red", "green", "blue", "yellow"),
  group  = LETTERS[1:4]
)

ggplot(df, aes(x, y)) +
  geom_text(aes(label = group, colour = group)) +
  geom_text(aes(x = 5 - x, label = colour, colour = I(colour)))

ggplot(df, aes(x, y)) +
  geom_text(aes(x = 5 - x, label = colour, colour = I(colour))) +
  geom_text(aes(label = group, colour = group))

Created on 2023-12-18 with reprex v2.0.2

@teunbrand teunbrand changed the base branch from main to rc/3.5.0 December 18, 2023 13:59
@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Dec 18, 2023
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand
Copy link
Collaborator Author

Thanks!

@teunbrand teunbrand merged commit 38c8796 into tidyverse:rc/3.5.0 Dec 18, 2023
12 checks passed
@teunbrand teunbrand deleted the AsIs_dispatch branch December 18, 2023 14:37
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
* skip AsIs scale type

* remove `scale_type.AsIs` method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order of <AsIs> may disrupt scales.
2 participants