[R] Dashed/dotted ecdf plots using lots of points

peter dalgaard pdalgd at gmail.com
Tue Jun 14 00:09:26 CEST 2016


(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

> On 13 Jun 2016, at 22:57 , A A via R-help <r-help at r-project.org> wrote:
> 
> 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?
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list