Turn off dotted lines in plot.ecdf()
Asked Answered
M

1

5

Plotting an ecdf object in R produces a nice empirical distribution function. E.g:

x = seq(1,10,1)
ecdf1 = ecdf(x)
plot(ecdf1,verticals=TRUE, do.points=FALSE)

However, the default behavior produces a figure with horizontal dotted lines at 0 and 1. I don't see an option to turn off this behavior in plot.ecdf() or in the underlying call to plot.stepfun(). Right now, I'm literally drawing a white line overtop the dotted lines.

Surely there's a way to turn off drawing these dotted lines?

ecdf figure

Miyamoto answered 2/2, 2016 at 20:32 Comment(0)
B
9

Try:

plot(ecdf1,verticals=T, do.points=F,col.01line = NULL)

enter image description here

Reasoning: I used getAnywhere("plot.ecdf") and found the line abline(h = c(0, 1), col = col.01line, lty = 2). That's the cause. Since it uses col.01line as its input for color, we simply set the color to NULL.

Benedict answered 2/2, 2016 at 20:36 Comment(2)
Good work, although sometimes you can just read the help page. In base-graphics the argument to a col parameter can also be "transparent".Rumanian
Thanks, and nice explanation on how you found the solution! Not sure how I missed that one.Miyamoto

© 2022 - 2024 — McMap. All rights reserved.