[R] stacked barplot with positive and negatvie values

Paul Magdon pmagdon at gwdg.de
Tue May 15 17:54:58 CEST 2007


Hello I'm trying to create a barplot with a couple of stacked positive 
values and with one negative value for each group.

example:

trees<-c(20,30,10)
shrubs<-c(12,23,9)
veg<-c(2,3,4)
soil<-c(-100,-123,-89)
example1<-t(cbind(trees,shrubs,veg))

barplot(example1)

#this works so far

#but now:

example2<-t(cbind(trees,shrubs,veg,soil))
barplot(example2)

This shows no more stacked bars. But I want to keep the bars like 
example1 and just add the negative values which have another scale 
downwards.
So I tried:

barplot(example1,axes=F)
barplot(example2["soil",],add=T,axes=F)
axis(side=2,at=c(-150,-100,-50,0,10,20,30))

But I still does not work for the axis??

I would appriciate any kind of hint
Greetings
Paul Magdon


-- 
_______________________________________________________________________
BSc. Paul Magdon
-Research Assistant-
Institute of Forest Management
Forest Assessment & Remote Sensing, Forest Growth, Forest Planning
Faculty of Forest Sciences and Forest Ecology
Georg-August-University Göttingen
Phone +49 551 39 3573
pmagdon at gwdg.de / skype: paul.magdon



More information about the R-help mailing list