Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ggsurvplot is it possible to start graph at (0,0)

I would like to have the axis crossing at 0,0 in ggsurvplot. There is a similar older question here ggsurvplot – axes crossing at 0,0. However, I am having errors with this method.

First error due to adding confidence intervals conf.int = T:

Error in ggpubr::geom_exec(.geom_confint, data = d, ymin = "lower", ymax = "upper", : object '.geom_confint' not found

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Second error occurs when adding median survival lines surv.median.line = "hv":

Error in .add_surv_median(p, fit, type = surv.median.line, fun = fun, : could not find function ".add_surv_median"

Is there another way to solve this?

ggsurvplot(fit, data = lung)

Thanks in forward

>Solution :

If I understand you right then you could achieve your desired result by removing the default expansion via scale_x/y_continuous like so:

library(survminer)
library(survival)

fit<- survfit(Surv(time, status) ~ sex, data = lung)

p <- ggsurvplot(fit, data = lung)

p$plot <- p$plot + 
  scale_x_continuous(expand = c(0, 0, .05, 0)) +
  scale_y_continuous(expand = c(0, 0, .05, 0))

p

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading