Vojtech Petr
Vojtech Petr

Reputation: 11

How to add line of text under the whole ggsurvplot?

I would like to add line of text under the whole plot. However, it seems ggsurvplot handles plot and risk-table as two entities. I would like to have it like this: enter image description here

However, this is added in MS Word and the journal asks to have it embedded in the picture itself and I am unable to do that.

Thank you :-)

ggsurvplot(fit = fit, data = dat, pval = TRUE, 
       color = "black", 
       risk.table = T,
       break.time.by = 12, 
       surv.scale = "percent",
       linetype = c("solid","dotted", "dashed"),
       legend.labs = c("Control group", "TMA R-ve", "TMA R+ve"), 
       censor.shape = 124, 
       legend.title = "",
       title = "5-years death-censored graft survival", 
       xlab = "Months from transplantation", 
       ylab = "Survival (%)")

Upvotes: 1

Views: 1076

Answers (1)

Ben
Ben

Reputation: 30474

I suppose there may be multiple approaches to laying out the plot, table, and text caption. Here is one way I thought might be easier to work with.

The ggsurvplot object, if you include the risk table, will have two ggplot objects contained in it, one for the curve plot, and one for the table (the table itself is a plot).

You can just add to the table plot a caption, and this will appear below the table in the end. If you include hjust = 0 with plot.caption it will be left justified.

Here is an example:

library(survival)
library(survminer)

fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurv <- ggsurvplot(fit, risk.table = TRUE)

ggsurv$table <- ggsurv$table +
  theme(plot.caption = element_text(hjust = 0)) +
  labs(caption = "Figure 1: 5-years death-censored graft survival")

ggsurv

ggsurvplot with figure text below table

Upvotes: 2

Related Questions