I plotted a histogram using Lattice
histogram(~Time |factor(Bila), data=flexi2, xlim= c(5, 15), ylim=c(0, 57),
scales=list(x=list(at=seq(5,15,1))), xlab="Time",
subset=(Bila%in% c("")))`
The bins I get do not match the exact hours, whereas I would like the bin to start at the exact hour, for example, 6,7 etc. I use lattice since I want conditional histograms. I have extracted here just one histogram to illustrate.
UPDATE: Here is a reproducible example (I hope) as was requested. As can be seen 0 for example is not at the limit of bins.
x<-rnorm(1000)
histogram(~x)
This happens because you specified the x axis scale with
scales = list(x = list(at = 5:15))
, but you didn't actually change the breakpoints. It happens in the default case as well: the default axis labels are integers, but the default breakpoints are determined programmatically and are not necessarily integers unless you have integer-valued data.An easy fix would be to specify your own breaks in the
breaks
argument:And an example: