eclarke / ggbeeswarm

Column scatter / beeswarm-style plots in ggplot2
GNU General Public License v3.0
531 stars 31 forks source link

`geom_beeswarm` returns error with one point and `priority = "density"` #90

Open MarekGierlinski opened 1 year ago

MarekGierlinski commented 1 year ago

Though ggbeeswarm is not designed to plot a single point, it should handle it with no errors. Here is a reprex, which generates an error:

library(ggplot2)
library(ggbeeswarm)

df <- data.frame(x = 1, y = 1)

ggplot(df, aes(x = x, y = y)) + geom_beeswarm(priority = "density")
#> Error in `geom_beeswarm()`:
#> ! Problem while computing position.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `density.default()`:
#> ! need at least 2 points to select a bandwidth automatically

This only happens when priority = "density", other priorities are handled correctly.