[R] ggplot barchart: bars don't stock on breaks

Boris Steipe boris.steipe at utoronto.ca
Mon Jan 12 15:03:54 CET 2015


Barcharts are for categorical data, the axis only serves to organize the category labels. From the sound of it, you are looking for a histogram.

Hope this helps,
Boris


On Jan 12, 2015, at 8:31 AM, najuzz <mjoey at gmx.de> wrote:

> Hi guys, I have the following weired problem. I just want a simple barchart,
> but the visuals are different from what I expect.
> 
> xx<-as.vector(xx)
> xx[1:4852]<-0
> xx[4853:5941]<-1
> table(xx)
> x<-data.frame(xx)
> 
> ggplot(x,aes(xx))+geom_bar(binwidth = 0.5)
> 
> <http://r.789695.n4.nabble.com/file/n4701665/problem.jpeg> 
> 
> I don't know if you can see the image so here is a description of my
> problem: the bars should be centered around O and 1, however both bars begin
> to the right of 0 and 1, so in this case with binwidth= 0.5 they range from
> 0 to 0.5 and 1 to 1.5.
> How can I fix this?
> 
> Thank you,
> Johannes
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/ggplot-barchart-bars-don-t-stock-on-breaks-tp4701665.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list