在PDF下着色区域

时间:2017-11-15 13:03:33

标签: r plot

我使用以下方法绘制Weibull分布W(2,3):

Weibull=function(x){
(2*x/9)*exp(-(x^2)/9)
}
xx=seq(from=0,to=10,length.out=1000)
xx1=Weibull(xx)
plot(xx,xx1,type="l")
polygon(xx, xx1, col = "red", border = NA)

PDF plot

我想仅在(4,10)之间遮蔽区域。我该怎么做呢?

1 个答案:

答案 0 :(得分:2)

xx2=seq(from=4,to=10,length.out=1000)
yy2=c(Weibull(xx2),0)
xx2=c(xx2,4)
plot(xx,xx1,type="l")
polygon(xx2, yy2, col = "red", border = NA)

Weibull