I've done it this way before: eX -> ecdf(distribution 1) eY -> ecdf(distribution 2) par(mar=c(5,5,2,1),xlog=TRUE) plot(eX, do.points=FALSE, verticals=TRUE, col="black", xlab=xlabel, xlim=c(1,100000), ylab=ylabel, lty=1, cex.lab=1.5, cex.axis=1.5, main="", lwd=3,log="x") plot(eY, do.points=FALSE, verticals=TRUE, col="blue", add=TRUE, xlim=c(1,100000), main="")
Warning: It makes a stair-step that may be difficult to see unless you use color. I had to change how the ecdf was plotted when I made b/w figures for my publication so that different dashed lines were distinct. HTH, -Steve -----Original Message----- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Wednesday, May 02, 2012 10:17 AM To: Johannes Radinger Cc: R-help@r-project.org Subject: Re: [R] Two ecdf with log-scales On May 2, 2012, at 6:14 AM, Johannes Radinger wrote: > Hi, > > i want to plot empirical cumulative density functions for two > variables in one plot. For better visualizing the differences in the > two cumulative curves I'd like to log-scale the axis. > > So far I found 3 possible functions to plot ecdf: > > 1) ecdf() from the package 'stats'. I don't know how to successfully > set the log.scales? Combining two plots is not a problem: > > plot(ecdf(x1)) > lines(ecdf(x2),col.h="red") > > 2) gx.ecdf() from package 'rgr'. It is easily possible to plot log- > scales, but I don't know how to plot two densities? > > gx.ecdf(x1,log=TRUE,ifqs = TRUE) > > 3) Ecdf() from package 'Hmisc'. No log-option directly available and > here I also don't know how to 'stack' two plots... > > Ecdf(x1,what="F") > > > Probably there are many more solutions (e.g. ggplot etc.)... > ...Has anyone faced a similar task and found a simple solution? Any > suggestions are welcome! Have you searched the Archives? I seem to remember that the log(0) was a barrier to persons attempting this in the past. (ISTR a posting in the last few weeks.) Maybe you could also provide a test data object that has the same range as your x1 and x 2 variables. > and provide commented, minimal, self-contained, reproducible code. -- David Winsemius, MD West Hartford, CT ______________________________________________ R-help@r-project.org mailing list 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.