Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions R/guide-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading