我想为各种线条绘制阴影置信区域,但是希望这些区域中的alpha级别从b到c逐渐变化,其中b是中位数的alpha,而c是我正在使用的任何外部分位数的alpha .以下代码生成我想要的线和置信区域图,但没有变量透明度.
x= 1:10+rnorm(10) xhigh=x+rnorm(10)^2 xlow=x-rnorm(10)^2 plot(x,type='l') polygon(x=c(1:length(xlow),length(xlow):1), y=c(xhigh,xlow[length(xlow):1]),col = rgb(1,0,0,.1),border=NA)
Axeman.. 5
您可以覆盖多个多边形:
plot(x,type='l') for (i in seq(0, 1, 0.01)) { polygon(x = c(x + i * (xhigh - x), x - i * (xlow - x)), col = rgb(1, 0, 0, .005), border = NA) }
尽管如此,我认为你的例子实际上是错误的,可能需要这样的东西:
plot(x,type='l') for (i in seq(0, 1, 0.01)) { polygon(x = c(1:10, 10:1), y = c(x + i * (xhigh - x), rev(x - i * abs(x - xlow))), col = rgb(1, 0, 0, .005), border = NA) }
您可以覆盖多个多边形:
plot(x,type='l') for (i in seq(0, 1, 0.01)) { polygon(x = c(x + i * (xhigh - x), x - i * (xlow - x)), col = rgb(1, 0, 0, .005), border = NA) }
尽管如此,我认为你的例子实际上是错误的,可能需要这样的东西:
plot(x,type='l') for (i in seq(0, 1, 0.01)) { polygon(x = c(1:10, 10:1), y = c(x + i * (xhigh - x), rev(x - i * abs(x - xlow))), col = rgb(1, 0, 0, .005), border = NA) }