diff --git a/R/theme.R b/R/theme.R index 49e28376a9..3611af323e 100644 --- a/R/theme.R +++ b/R/theme.R @@ -576,8 +576,9 @@ plot_theme <- function(x, default = theme_get()) { # Check that all elements have the correct class (element_text, unit, etc) validate_theme(theme) - - theme[intersect(names(theme), names(get_element_tree()))] + # Remove elements that are not registered + theme[setdiff(names(theme), names(get_element_tree()))] <- NULL + theme } #' Modify properties of an element in a theme object