How about this one?
breaks <- c(0,5,15,20,30,40)
counts <- c(0.2, 0.1, 1.2, 0.4, 0.4)
barplot(counts,
names=sprintf("[%g,%g)",
breaks[-length(breaks)], breaks[-1]
),
space=0
)
This will give you bars of equal widths. On the other hand, If you'd like to obtain bars of various widths, type:
barplot(counts, diff(breaks),
names=sprintf("[%g,%g)", breaks[-length(breaks)], breaks[-1]),
space=0
)
Moreover, this will give you an "ordinary" X axis:
barplot(counts, diff(breaks), space=0)
axis(1)
And if you'd like to get axis breaks exactly at points in breaks
, type:
axis(1, at=breaks)