Closed
Description
This is related to #2723, but really a distinct issue that I wanted to record separately. If a theme element is missing then R may decide to return a different one whose name partially matches. This can have unexpected results.
library(ggplot2)
t <- theme_void()
t$legend.box
#> NULL
t <- theme_void() + theme(legend.box.background = element_rect(fill = "gray80"))
t$legend.box
#> List of 5
#> $ fill : chr "gray80"
#> $ colour : NULL
#> $ size : NULL
#> $ linetype : NULL
#> $ inherit.blank: logi FALSE
#> - attr(*, "class")= chr [1:2] "element_rect" "element"
Created on 2018-06-28 by the reprex package (v0.2.0).