2

Consider the following series and cumulative plot:

x=c(0,0,0,0.5,10,1500)
qplot(x,geom='step',stat='ecdf')

This produces a graph that starts left of zero. In other words, it looks as if x has negative values. At the right it continues to the right after reaching 1500 and 100%. So, it looks as if there are x points larger than 1500.

I get what I expect when doing the whole thing manually:

xs=sort(x)   
qplot(xs,1:length(xs)/length(xs),x,geom='step')

But this seems to defy the whole purpose of the stat='ecdf' shortcut. What am I missing?

rcs
  • 61,470
  • 21
  • 164
  • 147
Henk
  • 3,428
  • 4
  • 26
  • 51

1 Answers1

0

By default stat_ecdf will pad the endpoints by max(0.08 * diff(rx), median(diff(xvals))). In my answer to In R ggplot2, include stat_ecdf() endpoints (0,0) and (1,1) I give a way of working around this, but it might be a little drastic, depending on your use case.

Community
  • 1
  • 1
user295691
  • 6,728
  • 1
  • 22
  • 33