[R] lines, ecdf and colors

Thomas Petzoldt thpe at simecol.de
Sat Nov 8 19:57:25 CET 2008


eric lee wrote:
> Hi.  I'm trying to plot two ecdf's on the same graph using two
> different colors.  I can plot using the same color, but it doesn't
> work when I change colors?  Any suggestions?  Thanks in advance for
> your help.
> 
> x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46)
> y <- c(1.15, 0.88, 0.90, 0.74, 1.21)
> plot(ecdf(x))
> # it works without col='blue', but doesn't with it
> lines(ecdf(y), col = "blue")

Does the following what you expect:

x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46)
y <- c(1.15, 0.88, 0.90, 0.74, 1.21)
plot(ecdf(x))
lines(ecdf(y), col.points  = "blue", col.hor = "blue")


See ?plot.ecdf and especially ?plot.stepfun for details.

HTH Thomas P.



More information about the R-help mailing list