Skip to content

Commit d1b519d

Browse files
authored
Don't prepopulate legend key sizes (#6340)
* don't prepopulate legend sizes * proper inheritance in colourbar size * add news bullet
1 parent 252e3c0 commit d1b519d

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@
325325
(@teunbrand, #3669).
326326
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
327327
(@teunbrand, #4335).
328+
* (internal) `legend.key.width` and `legend.key.height` calculations are no
329+
longer precomputed before guides are drawn (@teunbrand, #6339)
328330
* `ggsave()` can write a multi-page pdf file when provided with a list of plots
329331
(@teunbrand, #5093).
330332
* (internal) When `validate_subclass()` fails to find a class directly, it tries

R/guide-colorbar.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ GuideColourbar <- ggproto(
293293
# We set the defaults in `theme` so that the `params$theme` can still
294294
# overrule defaults given here
295295
if (params$direction == "horizontal") {
296-
theme$legend.key.width <- theme$legend.key.width * 5
296+
theme$legend.key.width <- rel(5)
297297
valid_position <- c("bottom", "top")
298298
} else {
299-
theme$legend.key.height <- theme$legend.key.height * 5
299+
theme$legend.key.height <- rel(5)
300300
valid_position <- c("right", "left")
301301
}
302302

R/guides-.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,6 @@ Guides <- ggproto(
491491
character(1), USE.NAMES = FALSE
492492
)
493493

494-
# Populate key sizes
495-
theme$legend.key.width <- calc_element("legend.key.width", theme)
496-
theme$legend.key.height <- calc_element("legend.key.height", theme)
497-
498494
grobs <- self$draw(theme, positions, theme$legend.direction)
499495
keep <- !vapply(grobs, is.zero, logical(1), USE.NAMES = FALSE)
500496
grobs <- grobs[keep]

0 commit comments

Comments
 (0)