survival (version 2.11-4)

plot.survfit: Plot Method for `survfit'

Description

A plot of survival curves is produced, one curve for each strata. The log=T option does extra work to avoid log(0), and to try to create a pleasing result. If there are zeros, they are plotted by default at 0.8 times the smallest non-zero value on the curve(s).

If legend.text is supplied a legend is created.

Usage

plot.survfit(x, conf.int=, mark.time=TRUE,
 mark=3, col=1, lty=1, lwd=1, cex=1, log=FALSE, xscale=1, yscale=1, 
 firstx=0, firsty=1, xmax, ymin=0, fun,
 xlab="", ylab="", xaxs="S", bty=NULL,
legend.text=NULL,legend.pos=0,legend.bty="n",main=NULL,...)

Arguments

x
an object of class survfit, usually returned by the survfit function.
conf.int
determines whether confidence intervals will be plotted. The default is to do so if there is only 1 curve, i.e., no strata.
mark.time
controls the labeling of the curves. If set to FALSE, no labeling is done. If TRUE, then curves are marked at each censoring time which is not also a death time. If mark.time is a numeric vector, then curves are m
mark
vector of mark parameters, which will be used to label the curves. The lines help file contains examples of the possible marks. The vector is reused cyclically if it is shorter than the number of curves.
col
a vector of integers specifying colors for each curve. The default value is 1.
lty
a vector of integers specifying line types for each curve. The default value is 1.
lwd
a vector of numeric values for line widths. The default value is 1.
cex
a numeric value specifying the size of the marks. Not a vector; all marks have the same size.
log
a logical value, if TRUE the y axis wll be on a log scale. Alternately, one of the standard character strings "x", "y", or "xy" can be given to specific logarithmic horizontal and/or vertical axes.
xscale
scale the x-axis values before plotting. If time were in days, then a value of 365.25 will give labels in years instead of the original days.
yscale
will be used to multiply the labels on the y axis. A value of 100, for instance, would be used to give a percent scale. Only the labels are changed, not the actual plot coordinates, so that adding a curve with "lines(surv.exp(...))

Value

  • a list with components x and y, containing the coordinates of the last point on each of the curves (but not the confidence limits). This may be useful for labeling.

item

  • firstx,firsty
  • xmax
  • ymin
  • fun
  • xlab
  • ylab
  • xaxs
  • bty
  • legend.pos
  • legend.bty
  • legend.text
  • main
  • ...

code

legend

BUGS

Survival curve objects created from a coxph model does not include the censoring times. Therefore, specifying mark.time=T does not work. If you want to mark censoring times on the curve(s) resulting from a coxph fit, provide a vector of times as the mark.time argument in the call to plot.survfit or lines.survfit.

See Also

par, survfit, lines.survfit legend

Examples

Run this code
data(aml)
leukemia.surv <- survfit(Surv(time, status) ~ x, data = aml)
plot(leukemia.surv, lty = 2:3)
legend(100, .9, c("Maintenance", "No Maintenance"), lty = 2:3)
title("Kaplan-Meier Curves
for AML Maintenance Study")


lsurv2 <- survfit(Surv(time, status) ~ x, aml, type='fleming')
plot(lsurv2, lty=2:3, fun="cumhaz",
	xlab="Months", ylab="Cumulative Hazard")

plot(leukemia.surv,lty=1:2,legend.pos=0,col=c("Red","Blue"),legend.text=c("Maintenance",
"No Maintenance"))
if (interactive()){
cat("Click on the graphics device to place a legend
")
plot(leukemia.surv,lty=2:3,legend.pos=locator(1),legend.text=c("Maintenance",
"No Maintenance"))
}

Run the code above in your browser using DataCamp Workspace