3

I am trying to plot a CDF plot using ecdf() function using the following code:

> 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

My dataset grows exponentially so I want to have log scale on x axis. When I don't use log="x" it works but the plot is not good. I need the x axis to be logarithmic. Any ideas?

Nasir
  • 1,982
  • 4
  • 19
  • 35
  • btw I tried adding `xlim=c(0,158600000)` but another error occured: `nonfinite axis limits [GScale(-inf,8.2003,1, .); log=1]` . – Nasir Jul 09 '12 at 15:42

1 Answers1

11

Here is some code that reproduces your problem:

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

Now, set the plot limits to 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] 

The solution: set the xlim to c(1, 1e9), i.e. set the lower limit to a positive number:

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

enter image description here

Andrie
  • 176,377
  • 47
  • 447
  • 496