From 720d744988e15be0041845dde5c5cfbd8757b3c4 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 5 Sep 2025 16:47:01 +0200 Subject: [PATCH] justify axis agnostic of label presence --- R/guide-axis.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/guide-axis.R b/R/guide-axis.R index 5f5aa9b8b1..97f85d1ed3 100644 --- a/R/guide-axis.R +++ b/R/guide-axis.R @@ -424,7 +424,6 @@ GuideAxis <- ggproto( # Unlist the 'label' grobs z <- if (params$position == "left") c(2, 1, 3) else 1:3 z <- rep(z, c(1, length(grobs$labels), 1)) - has_labels <- !is_zero(grobs$labels[[1]]) grobs <- c(list(grobs$ticks), grobs$labels, list(grobs$title)) # Initialise empty gtable @@ -452,13 +451,13 @@ GuideAxis <- ggproto( # Add null-unit padding to justify based on eventual gtable cell shape # rather than dimensions of this axis alone. - if (has_labels && params$position %in% c("left", "right")) { + if (params$position %in% c("left", "right")) { where <- layout$l[-c(1, length(layout$l))] just <- rotate_just(element = elements$text)$hjust %||% 0.5 gt <- gtable_add_cols(gt, unit(just, "null"), pos = min(where) - 1) gt <- gtable_add_cols(gt, unit(1 - just, "null"), pos = max(where) + 1) } - if (has_labels && params$position %in% c("top", "bottom")) { + if (params$position %in% c("top", "bottom")) { where <- layout$t[-c(1, length(layout$t))] just <- rotate_just(element = elements$text)$vjust %||% 0.5 gt <- gtable_add_rows(gt, unit(1 - just, "null"), pos = min(where) - 1)