Skip to content

Commit a315d8f

Browse files
committed
fix stretchy guide bug
1 parent 471a7e8 commit a315d8f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

R/guides-.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,13 @@ redistribute_null_units <- function(units, spacing, margin, type = "width") {
941941

942942
# Get spacing between guides and margins in absolute units
943943
size <- switch(type, width = width_cm, height = height_cm)
944-
spacing <- sum(rep(spacing, length.out = length(units) - 1))
944+
if (length(units) < 2) {
945+
# When we have 1 guide, we don't need any spacing
946+
spacing <- unit(0, "cm")
947+
} else {
948+
spacing <- sum(rep(spacing, length.out = length(units) - 1))
949+
}
950+
945951
margin <- switch(type, width = margin[c(2, 4)], height = margin[c(1, 3)])
946952
margin <- sum(size(margin))
947953

0 commit comments

Comments
 (0)