Skip to content

Ingest plain patterns as lists in layer() #5595

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

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

teunbrand
Copy link
Collaborator

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

Briefly, instead of coercing a plain pattern to a list in Geom$use_defaults(), it does so in the layer() function.
This has two consequences:

  1. Other internals, like GuideLegend$get_layer_key() or Geom$use_defaults() don't have to deal with plain patterns.
  2. If a pattern is provided to another aesthetic than 'fill', it is also coerced to a list, opening up 'fill'-variant aesthetics for patterns. For example, a package might use a 'fill_box' aesthetic for a geom.

Reprex from #5593:

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

grad <- grid::linearGradient(pal_viridis()(10))

ggplot(mpg, aes(factor(cyl), colour = "fixed")) +
  geom_bar(fill = grad)

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

@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 fe9d5bd into tidyverse:rc/3.5.0 Dec 18, 2023
@teunbrand teunbrand deleted the pattern_ingestion branch December 18, 2023 14:37
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
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.

2 participants