Survival plot: no decimal y-axis

Hello All,
I am plotting survival curve with ggsurvplot. That's ggsurvplot(survfit(Surv(years, mortality)~group, data = dat1, weights = w.ATT), fun='event', risk.table = T, legend.lab=c('1','2','3'), legend.title="",surv.scale='percent', break.time.by=2, xlab='years', legend='right', title="All-cause mortality", test.for.trend=T, pval.method.coord=c(5,10), conf.int=T, break.y.by=0.05)

On y-axis I only get percentage with a decimal,. but I'd like to have no decimal at all. I have tried with scale_y_continuous but it did not work.
any suggestion?

Hi @adcar,

I don't have the data you have, but here is an example with ggplot2. You can change the number of decimals with the accuracy = 0.1 argument.

library(survival)

cph <- coxph(Surv(time, status) ~ 1, lung)
km <- survfit(cph)

tibble(
  surv = km$surv,
  time = km$time
) %>% 
  ggplot(aes(time, surv)) + 
  geom_step() +
  scale_y_continuous(label = scales::number_format(accuracy = 0.1))

Created on 2020-01-15 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.