Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #2724. It supersedes #5335.

Briefly, it implements #2724 (comment) by using .subset2() as the dollar-subsetting method for themes.

Quick demo:

library(ggplot2)

# Old problematic behaviour
t <- theme(foobar = 12)
t$foo
#> [1] 12
t$foobar
#> [1] 12

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

# New correct behaviour
t$foo
#> NULL
t$foobar
#> [1] 12

Created on 2023-11-14 with reprex v2.0.2

@teunbrand teunbrand changed the title Theme partial match No partial matching in theme subsetting Nov 14, 2023
@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Nov 21, 2023
Co-authored-by: Thomas Lin Pedersen <[email protected]>
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 teunbrand merged commit 5f518d0 into tidyverse:main Nov 28, 2023
@teunbrand teunbrand deleted the theme_partial_match branch November 28, 2023 08:17
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.

R partial string matching can have unexpected results when theme elements are missing

2 participants