Skip to content

Commit 18b3623

Browse files
committed
fix stretchy guide bug
1 parent feb39c6 commit 18b3623

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/guides-.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,11 @@ 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+
spacing <- unit(0, "cm")
946+
} else {
947+
spacing <- sum(rep(spacing, length.out = length(units) - 1))
948+
}
945949
margin <- switch(type, width = margin[c(2, 4)], height = margin[c(1, 3)])
946950
margin <- sum(size(margin))
947951

0 commit comments

Comments
 (0)