繁体   English   中英

如何在R中绘制CDF

[英]How to plot CDF in R

我正在尝试使用ecdf()函数通过以下代码来绘制CDF图:

> x<-ecdf(data$V6)

> summary(x)
 Empirical CDF:   2402 unique values with summary
 Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
 3392     71870    120100    386100    219000 158600000 

plot(x, log='x')
    Error in plot.window(...) : Logarithmic axis must have positive limits

我的数据集呈指数增长,所以我想在x轴上显示对数刻度。 当我不使用log="x"它可以工作,但情节并不好。 我需要x轴是对数的。 有任何想法吗?

这里是一些代码重现您的问题:

x <- seq(2e3, 1e9, length.out=2000)
ex <- ecdf(x)
plot(ex, log="x")
Error in plot.window(...) : Logarithmic axis must have positive limits

现在,将绘图限制设置为c(0, 1e9)

plot(ex, xlim=c(0, 1e9), log="x")
Warning message:
In plot.window(...) : nonfinite axis limits [GScale(-inf,9,1, .); log=1]
Warning messages:
1: nonfinite axis limits [GScale(-inf,9,1, .); log=1] 
2: nonfinite axis limits [GScale(-inf,9,1, .); log=1] 

解决方案:将xlim设置为c(1, 1e9)c(1, 1e9)下限设置为正数:

plot(ex, xlim=c(1, 1e9), log="x")

在此处输入图片说明

暂无
暂无

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

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