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

Should undefined theme elements throw a warning instead of an error? #5719

Closed
teunbrand opened this issue Feb 28, 2024 · 0 comments · Fixed by #5743
Closed

Should undefined theme elements throw a warning instead of an error? #5719

teunbrand opened this issue Feb 28, 2024 · 0 comments · Fixed by #5743
Labels
messages requests for improvements to error, warning, or feedback messages themes 💃
Milestone

Comments

@teunbrand
Copy link
Collaborator

teunbrand commented Feb 28, 2024

This issue is a follow-up to #5702.
Instead of throwing errors, I think we should throw a warning and remove the offending element from the theme.

library(ggplot2)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  theme(foobar = "qux")
#> Error in `plot_theme()` at ggplot2/R/plot-build.R:178:3:
#> ! The `foobar` theme element is not defined in the element hierarchy.

Created on 2024-02-28 with reprex v2.1.0

@teunbrand teunbrand added themes 💃 messages requests for improvements to error, warning, or feedback messages labels Feb 28, 2024
@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
messages requests for improvements to error, warning, or feedback messages themes 💃
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant