You can use data from the summary()
to make your own plot with the confidence interval as polygon.
First, save the summary()
as an object. Data for plotting are located in variables time
, surv
, upper
and lower
.
mod<-summary(leukemia.surv)
Now you can use function plot()
to define the plotting region. Then with polygon()
plot confidence interval. Here you have to provide x values and x values in reverse order, and for y values use lower
values and revere upper
values. With function lines()
add survival line. By adding argument type="s"
to lines()
you will get line as steps.
with(mod,plot(time,surv,type="n",xlim=c(5,50),ylim=c(0,1)))
with(mod,polygon(c(time,rev(time)),c(lower,rev(upper)),
col = "grey75", border = FALSE))
with(mod,lines(time,surv,type="s"))