0

I try to edit the ylab in a ggsurvplot if I use the argument fun = "event". In this case, the ylab argument seems to be ignored and replaced by "cumulative event".

I used the code from this post Change x-axis labels for ggsurvplot for my attempt:

# code by Ian Campbell

tdata <- data.frame(time  =c(1,1,1,2,2,2,3,3,3,4,4,4),
                    status=rep(c(1,0,2),4),
                    n=c(12,3,2,6,2,4,2,0,2,3,3,5))
fit  <- survfit(Surv(time, time, status, type='interval') ~1,
                data=tdata, weight=n)


myplot <- ggsurvplot(fit, xlim = c(0,60), 
                     break.x.by = 20, xlab = "Day", ylab = "Survival probability", 
                     fun = "event",
                     risk.table = "abs_pct", font.x = c(26, face = "bold"), 
                     font.y = c(26, face = "bold"), font.tickslab = c(24), 
                     font.legend = c(24), risk.table.fontsize = 7, risk.table.col = "black", size = 1) 

myplot

Does anybody know what I do wrong?

Thank you!

MDStat
  • 355
  • 2
  • 17
  • That appears to be correct. If you use `fun = "event"` *and* you indicated `ylab = "Survival probability"`, then it will overwrite your `ylab` with `Cumulative event`. However, you can set `ylab` to something else - anything *but* "Survival probability" - and the `ylab` should change too. This should work even though `fun` is set to "event". Have you tried that? – Ben Sep 07 '21 at 11:24
  • I'm really sorry! You are absolutely right! I only tried "Survival probability" - this is obviously not allowed, but "test variable" of course is possible. Sorry, sorry, sorry!! Thank you for your answer! – MDStat Sep 07 '21 at 13:59

0 Answers0