Skip to content

Enable inheritance for derived theme elements #3550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2019

Conversation

clauswilke
Copy link
Member

This closes #3549.

library(ggplot2)

# like element_rect but with a meaningless dummy argument
element_dummyrect <- function(dummy) {
  structure(list(
    fill = NULL, colour = NULL, dummy = dummy, size = NULL,
    linetype = NULL, inherit.blank = FALSE
  ), class = c("element_dummyrect", "element_rect", "element"))
}

ggplot2:::calc_element(
  "panel.background",
  theme(
    rect = element_rect(fill = "white", colour = "black", size = 0.5, linetype = 1),
    panel.background = element_dummyrect(dummy = 5))
)
#> List of 6
#>  $ fill         : chr "white"
#>  $ colour       : chr "black"
#>  $ dummy        : num 5
#>  $ size         : num 0.5
#>  $ linetype     : num 1
#>  $ inherit.blank: logi FALSE
#>  - attr(*, "class")= chr [1:3] "element_dummyrect" "element_rect" "element"

Created on 2019-10-04 by the reprex package (v0.3.0)

@clauswilke clauswilke requested a review from thomasp85 October 4, 2019 22:05
@clauswilke
Copy link
Member Author

@thomasp85 Could you take a look at this? It would help me to have this fix in master. Thanks!

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clauswilke clauswilke merged commit f16f16f into tidyverse:master Oct 9, 2019
@clauswilke clauswilke deleted the theme-elements branch October 9, 2019 15:23
@lock
Copy link

lock bot commented Apr 15, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme element calculation fails for derived element classes
2 participants