Skip to content

<AsIs> never invokes identity scale - #5597

Merged
teunbrand merged 2 commits into
tidyverse:rc/3.5.0from
teunbrand:AsIs_dispatch
Dec 18, 2023
Merged

teunbrand merged 2 commits into
tidyverse:rc/3.5.0from
teunbrand:AsIs_dispatch

Conversation

@teunbrand

@teunbrand teunbrand commented Dec 18, 2023 •

Copy link
Copy Markdown
Collaborator

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

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@teunbrand

Copy link
Copy Markdown
Collaborator Author

Thanks!

@teunbrand
teunbrand merged commit 38c8796 into tidyverse:rc/3.5.0 Dec 18, 2023
@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