# 颜色设置:palettes. ggsurvplot(fit, data = lung, surv.median.line = "hv",legend.title = "sex", legend.labs = c("Male", "Female"), pval = TRUE,conf.int = TRUE,risk.table = TRUE, tables.height = 0.2,tables.theme =theme_cleantable(), palette = c("#E7B800", "#2E9FDF"))
# 同时改变font size, style and colorggsurvplot(fit, data = lung, main = "Survival curve", font.main = c(16, "bold", "blue"), font.x = c(14, "bold.italic", "red"), font.y = c(14, "bold.italic", "grey"), font.tickslab = c(12, "plain", "darkgreen"))
#接下来,我们将讲解如何在一张图片上绘制多个生存曲线,这里使用R内置数据colon(自变量更多)
#查看colon数据View(colon)
#我们选择自变量sex(性别)+ rx(治疗方式)+adhere(邻近器官)
#拟合多个生存曲线fit3 <- survfit( Surv(time, status) ~ sex + rx + adhere,data = colon )# 画多个生存曲线 ggsurvplot(fit3, data = colon, fun = "cumhaz", conf.int = TRUE, ggtheme = theme_bw())
#以上图形可以看出,图形复杂且杂乱,因此需要分割图片
# 分割开多个生存曲线 ggsurv<-ggsurvplot(fit3, data = colon, fun = "cumhaz", conf.int = TRUE, risk.table = TRUE, risk.table.col="strata", ggtheme = theme_bw())curv_facet <- ggsurv$plot + facet_grid(rx ~ adhere)curv_facet