Closed
Description
In the example below, the computation goes wrong because in the y-direction we don't have any width.
library(ggplot2)
df <- data.frame(x = 1:5, y = 1)
ggplot(df, aes(x, y)) +
geom_bin_2d()
#> Warning: Computation failed in `stat_bin2d()`.
#> Caused by error in `bin2d_breaks()` at ggplot2/R/stat-bin2d.R:64:5:
#> ! `origin` must be a number, not `NaN`.
Created on 2024-11-27 with reprex v2.1.1
I think the reasonable thing to do in such a case is to choose 1 bin for the y-direction with 1 width.