将标题添加到 ggsurvplot

Adding title to ggsurvplot

我想给 ggsurvplot 添加标题。这是我的代码:

library(survival)
library(survminer)

fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data =lung, main = "This is title")

它生成情节,但没有标题。如果添加 risk.table = TRUE,那么我会在风险 table 之上获得标题,但不是主要情节。

library(survival)
library(survminer)

fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data =lung, main = "This is title", 
           risk.table = TRUE)

知道如何解决吗?

title = 调用标题,而不是 main =.

ggsurvplot(fit, data =lung, title = "This is title", 
           risk.table = TRUE)

Output_Link_Here as I guess I'm too new to embed

如果您想将标题居中并将字体类型更改为粗体 and/or 对 ggplot 主题进行其他更改,请使用 + theme():

ggtheme = theme_minimal() + theme(plot.title = element_text(hjust = 0.5, face = "bold"))