This document explains Survival Curves related plotting using {ggplot2} and {ggfortify}.

Plotting with survival package

{ggfortify} let {ggplot2} know how to draw survival curves. After loading {ggfortify}, you can use ggplot2::autoplot function for survfit objects.

fit <- survfit(Surv(time, status) ~ sex, data = lung)

plot of chunk unnamed-chunk-1

There are some options to change survival curve output. Use help(autoplot.survfit) (or help(autoplot.*) for any other objects) to check available options.

autoplot(fit, surv.linetype = 'dashed', = FALSE,
         censor.shape = '*', censor.size = 5, facets = TRUE, ncol = 2)

plot of chunk unnamed-chunk-2

autoplot(survfit(Surv(time, status) ~ 1, data = lung), surv.colour = 'orange', censor.colour = 'red')

plot of chunk unnamed-chunk-2

autoplot(survfit(Surv(time, status) ~ sex, data = lung), fun = 'event')

plot of chunk unnamed-chunk-2

d.coxph <- survfit(coxph(Surv(time, status) ~ sex, data = lung))
autoplot(d.coxph, surv.linetype = 'dashed', surv.colour = 'blue', = 'dodgerblue3', = 0.5, censor = FALSE)

plot of chunk unnamed-chunk-2

Also, you can use autoplot for survival::aareg instance.

autoplot(aareg(Surv(time, status) ~ age + sex + ph.ecog, data = lung))

plot of chunk unnamed-chunk-3