From c404748de9ef50ee1b2ce869d4235a7f8ce0aae5 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 19 Feb 2025 14:59:25 +0100 Subject: [PATCH 1/3] don't prepopulate legend sizes --- R/guides-.R | 4 ---- 1 file changed, 4 deletions(-) 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] From 847ccdee849cae7228ebd04e3ade382cbca44912 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 19 Feb 2025 15:00:06 +0100 Subject: [PATCH 2/3] proper inheritance in colourbar size --- R/guide-colorbar.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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") } From c7c01c0784cc4342cb62524f5c2d2f6d9aeb9db3 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 19 Feb 2025 15:03:30 +0100 Subject: [PATCH 3/3] add news bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 74b049ace5..476f01ecf2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -306,6 +306,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) # ggplot2 3.5.1