Adjusting frequency of x-axis tickmarks in ggsurvplot

Viewed 1954

I am trying to increase the frequency of x-axis tickmarks in the ggsurvplot function from the package ggplot2 in R 3.5.1 using the argument xticks.by. But no matter what I input the tickmarks frequency stays the same. Adjusting y-axis tickmarks with the yticks.by argument seems to work.

Example code:

library(survival)
library(survminer)

data(ovarian)
data.frame(ovarian)

surv_object <- Surv(time = ovarian$futime, event = ovarian$fustat)
fit1 <- survfit(surv_object ~ rx, data = ovarian)
ggsurvplot(fit1, data = ovarian, xticks.by = 150)

Runnig this code gives the following plot witht he default x-axis tickmarks (300): Survival plot

What am I doing wrong?

1 Answers

You should use break.time.by

ggsurvplot(fit1, data = ovarian, break.time.by = 150)
Related