Skip to content

bins argument of geom_histogram and stat_bin argument off by 1 #1487

Closed
@alistaire47

Description

@alistaire47

When looking at this SO question, I realized that when I set the bins argument of geom_histogram or stat_bin, the resulting histogram has one more bin than the argument. For example:

ggplot(data = iris, aes(x = Sepal.Length)) + stat_bin(bins = 3)

produces
histogram with four bins

which certainly doesn't seem like what most people would expect. Is this a zero-based index issue?

Apologies if I'm missing something obvious, and thanks for all your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions