# [R] Plotting K-M Curve when have several strata

David Barron david.barron at jesus.ox.ac.uk
Wed Mar 26 13:25:30 CET 2003

```You could try something like:

plot(foo[1],conf.int=TRUE)
par(new=TRUE)
plot(foo[2],conf.int=TRUE,col=2)

Seems to work!

David

----- Original Message -----
From: "Ko-Kang Kevin Wang" <kwan022 at stat.auckland.ac.nz>
To: "R Help" <r-help at stat.math.ethz.ch>
Sent: Wednesday, March 26, 2003 12:13 PM
Subject: [R] Plotting K-M Curve when have several strata

> Hi,
>
> If I have:
>   foo <- survfit(y ~ x)
> where y is a survival object and x is a n-level factor.  The documentation
> says when I plot(foo), the confidence intervals will not be plotted (which
> I guess is understandable as otherwise the plot will get really messy).
>
> I tried to plot with confidence intervals by using:
>   plot(foo, conf.int = TRUE)
> and indeed the resulting plot is messy.  However I'm just wondering if I
> can (suppose x is a 2-level factor) use different colours and line types
> for the confidence lines?  If I do:
>   plot(foo, conf.int = TRUE, col = 1:2)
> then I'll get two different colours.  What I would like is to then plot
> the confidence lines using lty = 2 (while keeping the colour).
>
> Can I do this?
>
> --
> Cheers,
>
> Kevin
>
> --------------------------------------------------------------------------
----
> /* Time is the greatest teacher, unfortunately it kills its students */
>
> --
> Ko-Kang Kevin Wang
> Master of Science (MSc) Student
> SLC Tutor and Lab Demonstrator
> Department of Statistics
> University of Auckland
> New Zealand
> Homepage: http://www.stat.auckland.ac.nz/~kwan022
> Ph: 373-7599
>     x88475 (City)
>     x88480 (Tamaki)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>

```