-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add inherit.blank argument to element constructors #1754
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
Conversation
This seems like a reasonable approach to me |
@hadley can you review? Now you can do stuff like this (not a beautiful plot but an example): p + theme_minimal() + theme(line = element_blank(), axis.line.y = element_line()) |
What if we automatically set |
@@ -13,6 +13,8 @@ | |||
#' @param fill Fill colour. | |||
#' @param colour,color Line/border colour. Color is an alias for colour. | |||
#' @param size Line/border size in mm; text size in pts. | |||
#' @param inherit.blank Should this element inherit the existence of an | |||
#' element_blank among its parents? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you expand on this a little bit? I assume if it's TRUE
the "blank-ness" will be inherited, otherwise it will skip the parent and look at the grand parent?
|
||
if (is.null(e2) || inherits(e1, "element_blank")) return(e1) | ||
# If e1 is NULL inherit everything from e2 | ||
if (is.null(e1)) return(e2) | ||
# If e1 is NULL, or if e2 is element_blank, inherit everything from e2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment needs updating too, right?
# Conflicts: # R/theme-defaults.r
Edit: Just saw you updated your repo, but the following has not changed. Can you confirm my first example with your local branch? I like this idea. It would prevent the recursive checking that #1581 requires, but your example doesn't seem to work for me.
When I examine the plot theme, it seems When I try Examining the plot, I see
|
This has been fixed I think - truly with the latest version |
I cannot confirm any problems and all changes has been pushed - can you try again and make sure you create the plot object from scratch |
LGTM |
@thomasp85 Sorry, I previewed the comment but apparently never posted it. Yes, I've found no problems with the last update! |
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/ |
This PR is an alternative fix to #1555, #1557, #1565, and #1567 compared to #1581.
It will propose the inclusion of an
inherit.blank
argument to theelement_*
constructors. The reason for this is that we might want to suppress drawing of a parent element and all its children, and then reenable some of the children again. This requires element calculation to sometimes ignoreelement_blank()
and sometimes not. The default should beinherit.blank = FALSE
while elements in the included themes should haveinherit.blank = TRUE
instead.