3

我正在尝试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 轴是对数的。有任何想法吗?

4

1 回答 1

11

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

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),即将下限设置为正数:

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

在此处输入图像描述

于 2012-07-09T16:58:36.417 回答