Search code examples
rggplot2survival-analysisggally

How do I add shading and color to the confidence intervals in ggplot 2 generated Kaplan-Meier plot?


I would like to have the shading of the confidence intervals for the survival estimates. Now I have black lines.

library(survival)
library(ggplot2)
library(GGally)
data(lung) 
sf.sex <- survfit(Surv(time, status) ~ sex, data = lung) 
pl.sex <- ggsurv(sf.sex, CI = TRUE) 
pl.sex

enter image description here


Solution

  • I found a better solution. You just use the Rcmdrplugin KMggplot2 which also has the optional features of adding the median line and number at risk table.

    enter image description here