How can I plot two cumulative distributions curve as line type in same plot

纵饮孤独 提交于 2019-12-12 04:42:41

问题


I want to plot cumulative distributions curve for Weibull distribution over empirical cumulative distribution curve.

I have tried with this several times but it does not serve the way I want. Here is the command:

x<-(SIZEDIST$AVG.µm.)
x
plot(x,pweibull(x,shape=1.120662,scale=18.496778),type="l",col=4)
plot(ecdf(x),add=TRUE)

回答1:


Use lines instead of plot

plot(x,pweibull(x,shape=1.120662,scale=18.496778),type="l",col=4)
lines(ecdf(x),col='red')



回答2:


Like this?

set.seed(1)  # for reproducibility
# 1000 random samples from the Weibull dist
X <-rweibull(1000,shape=1.120662,scale=18.496778)
# z covers the range in X
z <- seq(min(x),max(x),length=100)
plot(z,pweibull(z,shape=1.120662,scale=18.496778),type="l",col=4, ylab="CDF")
plot(ecdf(x),add=TRUE)


来源:https://stackoverflow.com/questions/22437380/how-can-i-plot-two-cumulative-distributions-curve-as-line-type-in-same-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!