you can set the right bin width by setting the binwidth
and either center
or boundary
at the same time:
df <- data.frame(x = c(112.45, 2457.44, 333.24))
library(ggplot2) # 2.2.1
ggplot(df, aes(x)) + geom_histogram(binwidth = 100, center = 150)
# or
ggplot(df, aes(x)) + geom_histogram(binwidth = 100, boundary = 100)
center
The center of one of the bins. Note that if center is above or
below the range of the data, things will be shifted by an appropriate
number of widths. To center on integers, for example, use width = 1
and center = 0, even if 0 is outside the range of the data. At most
one of center and boundary may be specified.
boundary
A boundary
between two bins. As with center, things are shifted when boundary is
outside the range of the data. For example, to center on integers, use
width = 1 and boundary = 0.5, even if 0.5 is outside the range of the
data. At most one of center and boundary may be specified.
If you known the range of the data, you can also set this manually with breaks =
in geom_histogram
only.