kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
502 stars 162 forks source link

bug: ggsurvplot #442

Open Droopy2 opened 4 years ago

Droopy2 commented 4 years ago

Expected behavior

in ggsurvplot, using break.y.by should adjust the number of ticks on the y-axis

Actual behavior

break.y.by does not seem to work, removes most numbers from the y-axis

Steps to reproduce the problem

session_info()

# please paste here the result of
devtools::session_info()
fivetwigfire commented 3 years ago

The following reproduces the problem:

library(survival) library(survminer)

set.seed(42) n <- 100 df <- data.frame(e.time = sample(c(1:100), n, T), nn <- rpois(n, 1) )

df <- as.data.frame(lapply(df, rep, df$nn)) df$event <- 1

surv.obj <- with(df, Surv(e.time, event)) surv.fit <- survfit(surv.obj ~ NULL , data = df)

the error as encountered

ggsurvplot(surv.fit, fun = "event", conf.int = T, ylim = c(0,2), break.y.by = 0.1 )

no error without break.y.by

ggsurvplot(surv.fit, fun = "cumhaz", conf.int = T, ylim = c(0,2) )

error persists with break.y.by alone

ggsurvplot(surv.fit, fun = "cumhaz", conf.int = T, break.y.by = 0.1 )

does not occur for event plots

ggsurvplot(surv.fit, fun = "event", conf.int = T, break.y.by = .33 )

does occur for survival plots

ggsurvplot(surv.fit, fun = "pct", conf.int = T, break.y.by = 0.25 )