Skip to content

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

Closed
@teunbrand

Description

@teunbrand

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    messagesrequests for improvements to error, warning, or feedback messagesthemes 💃

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions