[R] Colors in survival plots

Thomas Lumley tlumley at u.washington.edu
Sun Jul 25 22:28:13 CEST 2004


On Sun, 25 Jul 2004, Min-Han Tan wrote:

> Hi,
>
> Sorry to trouble the list - I would like to ask a question - I can't
> find the answer in the r-help archives.
>
> I am trying to plot 2 survival curves in different colors.
>
> What I have tried is this
> plot(survfit(sim.surv ~ sim.km.smpl),col="red")
>
> but both the survival curves turn red...

Well, you did ask for them to be red :^)

The solution is to supply a vector of colors. For example

library(survival)
data(ovarian)
plot(survfit(Surv(futime,fustat)~rx, data=ovarian),
col=c("goldenrod","forestgreen"))


	-thomas




More information about the R-help mailing list