require(survival)
require(ggplot2)
f <- survfit(Surv(time, status) ~ trt, data = diabetic)
d <- with(f, data.frame(time, surv, lower, upper, trt=rep(names(f$strata), f$strata)))
ggplot(d, aes(x = time, y=surv)) +
geom_step(aes(color = trt)) +
geom_stepconfint(aes(ymin = lower, ymax = upper, fill = trt), alpha = 0.3) +
coord_cartesian(c(0, 50)) +
scale_x_continuous(expand = c(0.02,0)) +
labs(x = 'Time', y = 'Freedom From Event') +
scale_color_manual(
values = c('#d83641', '#1A45A7'),
name = 'Treatment',
labels = c('None', 'Laser'),
aesthetics = c('colour', 'fill'))
Run the code above in your browser using DataLab