I\'ve been looking for a solution to plot survival curves using ggplot2. I\'ve found some nice examples, but they do not follow the whole ggplot2 aesthetics (mainly regardin
You could try the following for something with shaded areas between CIs:
(I'm using the development version here as there's a flaw with the parameter alpha
in the production version (doesn't shade upper rectangles correctly for non-default values). Otherwise the functions are identical).
library(devtools)
dev_mode(TRUE) # in case you don't want a permanent install
install_github("survMisc", "dardisco")
library("survMisc", lib.loc="C:/Users/c/R-dev") # or wherever you/devtools has put it
data(kidney, package="KMsurv")
p1 <- autoplot(survfit(Surv(time, delta) ~ type, data=kidney),
type="fill", survSize=2, palette="Pastel1",
fillLineSize=0.1, alpha=0.4)$plot
p1 + theme_classic()
dev_mode(FALSE)
giving:
And for a classic plot and table:
autoplot(autoplot(survfit(Surv(time, delta) ~ type, data=kidney),
type="CI"))
See ?survMisc::autoplot.survfit
and ?survMisc::autoplot.tableAndPlot
for more options.