Skip to content

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

Description

@MarekGierlinski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions