Repository navigation
Conversation
thomasp85
reviewed
Aug 7, 2023
thomasp85
left a comment
Member
There was a problem hiding this comment.
calc_element() is a pretty meaty function to substitute in "just" to avoid partial matching... I'm a bit concerned about the impact on performance of this
|
|
||
| panel_table <- gtable_add_col_space(panel_table, | ||
| theme$panel.spacing.x %||% theme$panel.spacing) | ||
| calc_element("panel.spacing.x", theme)) |
Member
There was a problem hiding this comment.
we don't really use this indentation style in the codebase
Collaborator
Author
|
It is a about 2 milliseconds slower (out of 103/105 ms) on a facetted plot with 3 guides, which isn't too terrible I suppose. DetailsWith the current main branch: devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot(mtcars, aes(disp, mpg, colour = drat, fill = wt, size = cyl)) +
geom_point(shape = 21) +
facet_wrap(~ factor(gear))
b <- ggplot_build(p)
bench::mark(ggplot_gtable(b), iterations = 20)
#> # A tibble: 1 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 ggplot_gtable(b) 101ms 103ms 9.74 7.39MB 7.31Created on 2023-08-09 with reprex v2.0.2 With this PR: devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot(mtcars, aes(disp, mpg, colour = drat, fill = wt, size = cyl)) +
geom_point(shape = 21) +
facet_wrap(~ factor(gear))
b <- ggplot_build(p)
bench::mark(ggplot_gtable(b), iterations = 20)
#> # A tibble: 1 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 ggplot_gtable(b) 103ms 105ms 9.54 7.42MB 7.16Created on 2023-08-09 with reprex v2.0.2 |
Collaborator
Author
|
Closing this in favour of #5522 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to fix #2724.
Briefly, it replaces most instances of
theme$settingwithcalc_element("setting", theme).A particularly gnarly case was
guide_legend()that overrides inheritance, but I've tried to use double-bracket indexing in such cases. Also updated vignette with this, hopefully encouraging people to usecalc_element()instead.