我试图给曲线的包络上色。 比如说:
set.seed(1)
middle = seq(1,10,length.out=100)
upper = middle+5*runif(100)
lower = middle-5*runif(100)
plot(seq(100),middle,ylim=range(lower,middle,upper),type='l',col='red')
lines(upper,col='grey')
lines(lower,col='grey')
如何在灰线之间以灰色显示颜色?
答案 0 :(得分:4)
这是一种可能性,如demo(graphics)
middle <- seq(1,10,length.out=100)
upper <- middle+5*runif(100)
lower <- middle-5*runif(100)
xx <- c(1:100,100:1)
yy <- c(upper,rev(lower))
plot(seq(100),middle,ylim=range(lower,middle,upper),type='l')
polygon(xx, yy, col="gray")
lines(seq(100),middle,ylim=range(lower,middle,upper),type='l',col='red')
答案 1 :(得分:3)