Skip to content

geom_histogram stat_bin computation fails if data = 0.25 #3606

Closed
@lizlaw

Description

@lizlaw

Hello, if I try to create a histogram with a vector of 0.25's the stat_bin computation fails (plots an empty plot) with the warning:
Warning message:
Computation failed in stat_bin():
invalid number of intervals.
I am guessing it is something to do with how it calculates the bins if all the data are equal? All other values I have tried are fine.
Cheers

library(ggplot2)
ggplot() + geom_histogram(aes(x= rep(0.25,10))) # Fails
ggplot() + geom_histogram(aes(x= rep(0.15,10))) # Normal
ggplot() + geom_histogram(aes(x= rep(0.35,10))) # Normal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions