[R] Stacked bar plot anomaly When column contains a negative and a positive value

Murray Richardson murray.richardson at utoronto.ca
Sat May 3 21:29:41 CEST 2008


Hello users,

I've noticed a problem when creating a stacked column plot when a column 
contains a negative and a positive value.  e.g.

series1<-c(-1,-2, 3, 4, 5)
series2<-c( 5, -4,-3,-2, 1)
data<-rbind(series1,series2)
barplot(as.matrix(data), beside=FALSE)


In these cases (i.e. first, third and fifth columns) the plotting is not 
handled correctly. Compare this output with that of:


barplot(as.matrix(data), beside=TRUE)


Shouldn't the plots look the same except in the beside=FALSE scenario 
the constituent bars should not be juxtaposed but instead are one on top 
of the other?

Thanks for any advice!

Murray Richardson



More information about the R-help mailing list