How to set custom x axis interval in survival plot?

1.1k Views Asked by At

How to change the x axis intervals to 1,10,20...100 instead of 0,25,50,100 ? I used folloing code to generate the survival plot

library(survminer)
library(tibble)
library(survival)
library(data.table)

#Create dataframe
datam = data.table(ID=1:100,
                  AGE= sample(20:90, size = 100, replace = T),
                  Cancer = sample(0:1, 100, replace = T),
                  Sex = rep(c("Male","Female"), 50))
surviv <- as_tibble(datam)

#Create sfit object
sfit <- survfit(Surv(AGE, Cancer)~Sex, data=surviv)

#Plot the survival analysis
ggsurvplot(sfit, conf.int = FALSE, legend = "bottom",
           palette = c("red", "blue"),legend.title="Sex",
           risk.table = TRUE, risk.table.col = "strata",
           legend.labs=c("Male", "Female"),
           xlim=c(0,100),xscale = 1,
           ggtheme = theme_survminer(),
           xlab = "Age at Diagnosis", size=1.5,
           ylab="Cumulative Risk", pval = FALSE,
           fun = "event")

Survival_plot

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the option break.x.by=10

ggsurvplot(sfit, conf.int = FALSE, legend = "bottom",
           palette = c("red", "blue"),legend.title="Sex",
           risk.table = TRUE, risk.table.col = "strata",
           legend.labs=c("Male", "Female"),
           xlim=c(0,100),xscale = 1,
           ggtheme = theme_survminer(),
           xlab = "Age at Diagnosis", size=1.5,
           ylab="Cumulative Risk", pval = FALSE,
           fun = "event", break.x.by=10)

Survivsl Plot