Skip to content

Dashed/dotted ecdf plots using lots of points

2 messages · a a, Peter Dalgaard

a a
#
As per the title, I'd like to generate a dashed/dotted CDF plot of my data using ecdf. Unfortunately, it seems like I can't get the plot to look dashed/dotted even after specifying it in the plot function. I suspect this may be because of the high number of data points. Here's a short sample of code that illustrates my issue:
#change to 1:100 to see the dotted line
x = 1:10000
e = ecdf(x)
plot(e,do.p=FALSE, lty = "dotted")
Is there a way to solve this problem?
#
(a) ecdf() could be an overkill for this. At 10000 points, plot(sort(x), ppoints(x), type="l") should be quite close enough. Also, plot.ecdf() draws lots of individual horisontal line segments which all start in the same way. If you have enough of them, they reduce to a single pixels which are all "on". If you draw a continuous line, at least there is a chance to get dotting and dashing to work. However...

(b) It is a generic problem to get dash/dot patterns to cycle correctly along multisegment lines. Some device drivers are better at it than others. 

The following looks OK for me, but not on the quartz() screen device. 

pdf()
x <- rnorm(10000)
plot(sort(x),ppoints(x),type="l",lty="dashed", ylim=c(0,1))
plot(sort(x),ppoints(x),type="l",lty="dotted", ylim=c(0,1))
dev.off()

-pd