简体   繁体   English

是否可以使用cdf在一个图中绘制多个ecdf和cdf?

[英]Is it possible to plot multiple ecdf and cdf in one plot using cdf?

I'm making a cdf for my dataset x,y, and z. 我正在为我的数据集x,y和z制作一个cdf。 How do I put them in one plot? 我如何将它们放在一个图中?

Im using fitdist to obtain the ecdf and cdf for x,y, and z. 我使用fitdist获取x,y和z的ecdf和cdf。

  ## Say if we have 
  x=runif(30)
  y=runif(30) 
  z=runif(30)

  ## To fit the distribution I used fitdist 
   a=fitdist(x, "norm")
   b=fitdist(y, "norm")
   c=fitdist(z, "norm")

   par(mfcol=c(1,3))
   cdfcomp(a, xlab="yield loss", ylab="probability", main="1st Stage",      datacol="black", fitcol="green")
   cdfcomp(b, xlab="yield loss", ylab="probability", main="2nd Stage",datacol="gray", fitcol="blue")
   cdfcomp(c, xlab="yield loss", ylab="probability",main="3rd Stage",datacol="navy", fitcol="red")

These codes give a three separate plots. 这些代码给出了三个单独的图。 Is there a way to put them in the same plot? 有没有办法把它们放在同一个情节中?

I tried doing 我试过了

    cdfcomp(list(a,b, c), horizontals = FALSE)

but it gives the following message 但它给出了以下信息

   "Error in FUN(X[[i]], ...) : 
    All compared fits must have been obtained with the same dataset."

What do I do? 我该怎么办?

It is possible, use add = TRUE : 有可能,使用add = TRUE

library(fitdistrplus)
x=runif(30)
y=runif(30) 
z=runif(30)
a=fitdist(x, "norm")
b=fitdist(y, "norm")
c=fitdist(z, "norm")
cdfcomp(a, xlab="yield loss", ylab="probability", datacol="black", fitcol="green")
cdfcomp(b, datacol="gray", fitcol="blue", add = TRUE)
cdfcomp(c, datacol="navy", fitcol="red", add = TRUE)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM