将图拆分为 3 阶乘条形图的上方和下方部分
我需要根据 3 个因素绘制地上和地下生物量的条形图。对于每个生物量,我可以使用点阵中的条形图来绘制它,但是,我不知道如何绘制其中两个,即地上生物量在 Y 轴的正值部分,地下生物量在 Y 轴的负值部分。这是我的数据的测试代码,其中 A、B、C 是全阶乘因子:
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))
但是 3 个因子怎么样?
我对网格绘图系统很陌生,所以,任何想法都非常受欢迎 祝
一切顺利
Marco
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法:
例如:
Here is one way of doing it:
For example: