I am trying to figure out how to make barplot where I can show two data sets. Each at one side of the y-axis. I need the space for showing many data sets in few graphs. stacked or besides are other options but I would like to find out how to solve this task specially I have started to play around a little
#creating data
names<-LETTERS[1:9]
data1<-c(8, 6, 3, 2, 0, 1, 1, 3, 1)
data2<-c(0, -1, 0, 0, 0, 0, 0, -2, -1)#negative to show them on the
#left side of yaxis
data1<-matrix(data1,ncol=9,nrow=1,byrow=F)
dimnames(data1)<-list(1,names)
data2<-matrix(data2,ncol=9,nrow=1,byrow=F)
dimnames(data2)<-list(1,names)
par(fig=c(0.5,1,0,1)) # making space for the "left" barplot
barplot(data1,horiz=T,axes=T,las=1)
par(fig=c(0.35,0.62,0,1), new=TRUE)#adjusting the "left" barplot
#because the labels would be negative
# use of axes=F
barplot(data2,axes=F,horiz=T,axisnames=FALSE)
#creating a new axis with desired labels
axis(side=1,at=seq(-8,0,2),labels=c(8,6,4,2,0))
But I have difficulties to understand the concept behind fig=c(...) How can I ad a xaxis for my "left" barplot which has the same lenght i.e running from 0:8 like the other one
Thanks Alex