diff --git a/NEWS.md b/NEWS.md index 823adbcfa8..8123476047 100644 --- a/NEWS.md +++ b/NEWS.md @@ -324,6 +324,8 @@ (@teunbrand, #3669). * Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)` (@teunbrand, #4335). +* (internal) `legend.key.width` and `legend.key.height` calculations are no + longer precomputed before guides are drawn (@teunbrand, #6339) * `ggsave()` can write a multi-page pdf file when provided with a list of plots (@teunbrand, #5093). * (internal) When `validate_subclass()` fails to find a class directly, it tries diff --git a/R/guide-colorbar.R b/R/guide-colorbar.R index 287b0087b8..5116e1b24b 100644 --- a/R/guide-colorbar.R +++ b/R/guide-colorbar.R @@ -293,10 +293,10 @@ GuideColourbar <- ggproto( # We set the defaults in `theme` so that the `params$theme` can still # overrule defaults given here if (params$direction == "horizontal") { - theme$legend.key.width <- theme$legend.key.width * 5 + theme$legend.key.width <- rel(5) valid_position <- c("bottom", "top") } else { - theme$legend.key.height <- theme$legend.key.height * 5 + theme$legend.key.height <- rel(5) valid_position <- c("right", "left") } diff --git a/R/guides-.R b/R/guides-.R index 83ced80cd7..b6da9f723d 100644 --- a/R/guides-.R +++ b/R/guides-.R @@ -491,10 +491,6 @@ Guides <- ggproto( character(1), USE.NAMES = FALSE ) - # Populate key sizes - theme$legend.key.width <- calc_element("legend.key.width", theme) - theme$legend.key.height <- calc_element("legend.key.height", theme) - grobs <- self$draw(theme, positions, theme$legend.direction) keep <- !vapply(grobs, is.zero, logical(1), USE.NAMES = FALSE) grobs <- grobs[keep]