Skip to content

Kaplan-Meier Plot

3 messages · John Lande, Marc Schwartz

#
on 01/14/2009 03:32 PM John Lande wrote:
John,

Is this what you want?


par(mfrow = c(2, 1))

# Normal plot
plot(survfit(Surv(time, status) ~ x, data = aml))


# Set par(lwd = 3) to increase the thickness of the censoring marks
# Don't frame the plot region, as it uses par(lwd)
par(lwd = 3)
plot(survfit(Surv(time, status) ~ x, data = aml), frame = FALSE)

# Reset par(lwd) to normal to frame the plot region
par(lwd = 1)
box()


Note that given the way in which the plot code has been set up, using
'lwd' in the function call affects the survivorship function line and
not the censoring marks. By setting par(lwd = 3) prior to the plot call,
this will be used internally when the marks are plotted using points(),
without affecting the other lines, save the plot region frame.

Just so that you don't think that you missed something obvious, this was
a little trial and error after reviewing the R code for
survival:::plot.survfit to see how the arguments from the function call
are passed to the internal plotting functions. Combined also with some
knowledge of how the graphic pars are handled...

HTH,

Marc Schwartz