Skip to content

Commit 0a78c90

Browse files
committed
1 parent 3870c12 commit 0a78c90

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/bin.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ bin_breaks_width <- function(x_range, width = NULL, center = NULL,
8787
max_x <- x_range[2] + (1 - 1e-08) * width
8888
breaks <- seq(origin, max_x, width)
8989

90-
if (length(breaks) > 1e6) {
90+
if (length(breaks) == 1) {
91+
# In exceptionally rare cases, the above can fail and produce only a
92+
# single break (see issue #3606). We fix this by adding a second break.
93+
breaks <- c(breaks, breaks + width)
94+
} else if (length(breaks) > 1e6) {
9195
stop("The number of histogram bins must be less than 1,000,000.\nDid you make `binwidth` too small?", call. = FALSE)
9296
}
9397

0 commit comments

Comments
 (0)