Hi R Folks, I need to plot a stacked bar plot with row labels as A,B,C,... and each bar divided by x,y,.... Here is the data: x y A 1 .5 B -.2 .6 C .3 -.7 D .4 .8 (for e.g. x,y,... could be air pollutants and A,B,C,... could be months) Issue 1) It has negative values. Issue 2) It contain two categorical variables. Can anyone help me? Thanks, Gary [[alternative HTML version deleted]]
On Nov 20, 2009, at 6:54 PM, Gary wrote:> Hi R Folks, > > I need to plot a stacked bar plot with row labels as A,B,C,... and > each bar > divided by x,y,.... Here is the data: > > x y > A 1 .5 > B -.2 .6 > C .3 -.7 > D .4 .8 > (for e.g. x,y,... could be air pollutants and A,B,C,... could be > months)At the moment the letters appear to be labels.> > Issue 1) It has negative values. > Issue 2) It contain two categorical variables."It"??? (In my opinion, the indefinite pronoun should be severely deprecated in technical discourse.)> > Can anyone help me?RSiteSearch("stacked barplot") # 44 hits> > Thanks, > Gary > > > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT
tmp <- cbind(x=c(1,-.2,.3,.4), y=c(.5,.6,-.7,.8)) row.names(tmp) <- letters[1:4] barchart(tmp, horizontal=FALSE, stack=TRUE, auto.key=list( title="pollutant", border=TRUE), xlab="Month", main="Interesting Plot") barchart(tmp, horizontal=FALSE, stack=TRUE, auto.key=list( title="pollutant", cex.title=1.2, border=TRUE), xlab="Month", ylab="something else", main="Interesting Plot")