I need to barplot the above- and belowground biomass against 3 factors. For each biomass, I am able to plot it using the barchart from lattice, however, I have no idea as to plot two of them, ie, aboveground biomass on the positive, and belowground on the negetive part of the Y axis. Here is the test code for my data, where A, B, C are full factorial factors:
library(lattice)
above <- runif(108)
below <- runif(108)
A <- rep(c("ab", "bc", "cd"), each=36)
B <- rep(1:3, 36)
C <- gl(3, 4, 108, c(30, 60, 90))
barchart(above~A|B+C)
barchart(below~A|B+C)
#This is what I used to do for two factors using barplot
par(mfrow=c(2, 1), mai=c(0, 1, 0.5, 0.5))
agg.abv <- aggregate(above, by=list(A, B), mean)
abv <- matrix(agg.abv[, 3], ncol=nlevels(A), dimnames=list(levels(A), levels(B)))
agg.bel <- aggregate(below, by=list(A, B), mean)
bel <- matrix(agg.bel[, 3], ncol=nlevels(A), dimnames=list(levels(A), levels(B)))
barplot(abv, beside=T, ylim=c(0, 1))
barplot(abv, beside=T, ylim=c(1, 0))
but how about 3 factors?
I am quite new to trellis ploting system, so, any idea is very welcome
All the best
Marco
Here is one way of doing it:
For example: