Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding title to ggsurvplot

I would like to add title to ggsurvplot. Here is my code:

library(survival)
library(survminer)

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

It generates plot, but without title. If add risk.table = TRUE, then I get title on top of risk table, but not the main plot.

library(survival)
library(survminer)

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

ggsurvplot title

Any idea how to fix it?

like image 914
user1700890 Avatar asked Aug 17 '26 19:08

user1700890


1 Answers

Call the title with title = , not with main =.

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

Output_Link_Here as I guess I'm too new to embed

like image 114
j.Rinehart Avatar answered Aug 19 '26 11:08

j.Rinehart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!