Skip to content

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

@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