[R] ggplot2 histograms

Hadley Wickham hadley at rice.edu
Wed Dec 1 15:27:33 CET 2010


> However if you do:
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, position = position_dodge(width=0.99))
>
> The position of first bin which goes from 0-2 appears to start at about 0.2 (I accept that there is some "white space" to the left of this) while the position of the last bin (16-18) appears to start at about 15.8, so the whole histogram seems to be wrongly compressed into the scale. In my real data which has potentially 250 bins the problem becomes much more pronounced. Has any one else noticed this? Is there a work around?

What do you expect this to do?  The bars are one unit wide, but you've
told position_dodge to treat them like they're only 0.99 units wide.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list