Skip to content

R partial string matching can have unexpected results when theme elements are missing #2724

Closed
@clauswilke

Description

@clauswilke

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions