如何使用Survminer包優(yōu)雅的繪制生存曲線?
# 顏色設置: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內(nèi)置數(shù)據(jù)colon(自變量更多)
#查看colon數(shù)據(jù)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

請輸入評論內(nèi)容...
請輸入評論/評論長度6~500個字
圖片新聞