[R] ggplot2: Histogram with negative values on x-axis doesn't work

Karl Ove Hufthammer karl at huftis.org
Wed Oct 21 14:11:14 CEST 2009


In article <OF1D427087.01614A71-ONC1257656.003BFAB8-C1257656.003C88F8
@basf-c-s.be>, sebastian.rohrer at basf.com says...
> I have a dataset that contains numbers between -10 and 0. E.g. x = 
> c(-9.23, -9.56, -1.40, ...)
> If I no do a
> > qplot(x, geom="histogram")
> I get the error:
> Error: position_stack requires non-overlapping x intervals
> Strangely, the following both work:
> > qplot(x * -1, geom="histogram")
> > qplot(x+100, geom="histogram")

I can reproduce it with for example
x=c(-9.23, -9.56, -1.40)

But adding a single positive number, even .0000001, fixes it, while 
adding a similar negative number introduces a new error message, so it 
really looks like a bug in ggplot2 when all the values are negative.

Report it to the ggplot2 author or the ggplot2 mailing list.

-- 
Karl Ove Hufthammer




More information about the R-help mailing list