ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Only use finite breaks for computing fuzz

Open teunbrand opened this issue 5 months ago • 0 comments

This PR aims to fix #5665.

Briefly, when histogram breaks are short and contain non-finite values, the median difference between breaks can become Inf. In this PR, we only use finite breaks to compute the median difference for the fuzz-factor.

Reprex from #5665

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

data <- data.frame(x = c(rep(1, 10), 5))

ggplot(data, aes(x)) +
  geom_histogram(
    breaks = c(-Inf, 2, 6, Inf),
    closed = "left"
  )
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_bar()`).

Created on 2024-01-30 with reprex v2.1.0

teunbrand avatar Jan 30 '24 08:01 teunbrand