Skip to content

geom_hex ignores binwidth argument when sample size is small #4580

Closed
@sieste

Description

@sieste

geom_hex ignores the binwidth argument when there are only few data points:

library(ggplot2)
n = 1
ggplot(tibble(x=rnorm(n), y=rnorm(n))) + 
  geom_hex(aes(x=x, y=y), binwidth=c(.1,.1)) + 
  xlim(-3, 3) + ylim(-3,3)

For small values of n (below 10) the bin widths are not 0.1. For larger n (try 100), the problem goes away and the bin width is 0.1 as specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorlayers 📈

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions