Skip to content

Commit 0f783ce

Browse files
authored
Justify axis agnostic of label presence (#6590)
* justify axis agnostic of label presence * add news bullet
1 parent c094b4b commit 0f783ce

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
legend glyphs (@teunbrand, #6594)
2525
* Fixed regression where `NULL`-aesthetics contributed to plot labels too
2626
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
27+
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
2728

2829
# ggplot2 4.0.0
2930

R/guide-axis.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ GuideAxis <- ggproto(
424424
# Unlist the 'label' grobs
425425
z <- if (params$position == "left") c(2, 1, 3) else 1:3
426426
z <- rep(z, c(1, length(grobs$labels), 1))
427-
has_labels <- !is_zero(grobs$labels[[1]])
428427
grobs <- c(list(grobs$ticks), grobs$labels, list(grobs$title))
429428

430429
# Initialise empty gtable
@@ -452,13 +451,13 @@ GuideAxis <- ggproto(
452451

453452
# Add null-unit padding to justify based on eventual gtable cell shape
454453
# rather than dimensions of this axis alone.
455-
if (has_labels && params$position %in% c("left", "right")) {
454+
if (params$position %in% c("left", "right")) {
456455
where <- layout$l[-c(1, length(layout$l))]
457456
just <- rotate_just(element = elements$text)$hjust %||% 0.5
458457
gt <- gtable_add_cols(gt, unit(just, "null"), pos = min(where) - 1)
459458
gt <- gtable_add_cols(gt, unit(1 - just, "null"), pos = max(where) + 1)
460459
}
461-
if (has_labels && params$position %in% c("top", "bottom")) {
460+
if (params$position %in% c("top", "bottom")) {
462461
where <- layout$t[-c(1, length(layout$t))]
463462
just <- rotate_just(element = elements$text)$vjust %||% 0.5
464463
gt <- gtable_add_rows(gt, unit(1 - just, "null"), pos = min(where) - 1)

0 commit comments

Comments
 (0)