标准条形图也可以,您只需将数据放入矩阵中。例子:
L <- data.frame(point = c(3, 5, 6, 7, 8, 9, 11),
layer1 = c(1, 25, 20, 90, 80, 100, 45),
layer2 = c(5, 20, 0, 0, 0, 70, 0),
layer3 = c(80, 5, 0, 0, 0, 0, 0))
barplot(t(as.matrix(L)),col=c("blue","black","yellow","orange"))

做你想要的意味着循环:
L <- data.frame(
layer1 = c(25, 20, 90, 80, 100, 45),
layer2 = c(5, 20, 0, 0, 70, 0),
layer3 = c(80, 5, 0, 0, 0, 0))
rownames(L)<-c(3, 5, 6, 7, 8, 9)
AL_col <- matrix(c(
4,3,3,3,3,3,
5,5,6,6,6,5,
4,3,6,6,6,6),ncol=6,byrow=TRUE)
colnames(AL_col) <- c("point3","point5","point6","point7","point8","point9")
rownames(AL_col) <- c("layer1","layer2","layer3")
col1<-c("green","brown","purple","black","yellow", "white","blue")
# the problem is then to make polygons corresponding to your colors
maxHeight <- max(as.matrix(L) %*% rep(1,dim(L)[2]))
widthPol <- 0.5
plot(c(1-widthPol,dim(L)[1]+widthPol),c(0,maxHeight),type="n",xlab="Points",ylab="Height")
for(iPoint in 1:6){
currentY <- 0
for(iLayer in 1:3){
addedY <- L[iPoint,iLayer]
if(addedY>0){
xs <- c(rep(iPoint-widthPol/2,2),rep(iPoint+widthPol/2,2))
ys <- c(0,addedY,addedY,0)
colPoly <- col1[AL_col[iLayer,iPoint]]
polygon(x=xs,y=ys+currentY,col=colPoly)
currentY <- currentY + addedY
}
}
}
