如何在 r 中绘制此图
how to plot this figure in r
我正在尝试在 r 中绘制此图,如何添加线条和颜色?
x=seq(0,1,0.01)
z1=dbeta(x,1,1)
y=1
n=3
z2=dbeta(x,1+y,1+n-y)
m1=data.frame(cbind(z2,z1))
matplot(x,m1,type="l",lwd=2,cex.main=1,col=c("black","black"))
您可以通过添加多边形来添加密度曲线下的区域。边界取决于 seq
中的 x
(x 中所需的间隔)以及当 x
位于 x
的选定间隔之间时的 m1$z2
值.
polygon(c(.3, x[x >= .3 & x <= .4], .4),
c(0, m1$z2[x >= .3 & x <= .4], 0), col="red")
polygon(c(.2, x[x >= .2 & x <= .3], .3),
c(0, m1$z2[x >= .2 & x <= .3], 0), col="light blue")
我正在尝试在 r 中绘制此图,如何添加线条和颜色?
x=seq(0,1,0.01)
z1=dbeta(x,1,1)
y=1
n=3
z2=dbeta(x,1+y,1+n-y)
m1=data.frame(cbind(z2,z1))
matplot(x,m1,type="l",lwd=2,cex.main=1,col=c("black","black"))
您可以通过添加多边形来添加密度曲线下的区域。边界取决于 seq
中的 x
(x 中所需的间隔)以及当 x
位于 x
的选定间隔之间时的 m1$z2
值.
polygon(c(.3, x[x >= .3 & x <= .4], .4),
c(0, m1$z2[x >= .3 & x <= .4], 0), col="red")
polygon(c(.2, x[x >= .2 & x <= .3], .3),
c(0, m1$z2[x >= .2 & x <= .3], 0), col="light blue")