Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggsurvplot() and axes offset from the origin #196

Closed
kassambara opened this issue Apr 16, 2017 · 7 comments
Closed

ggsurvplot() and axes offset from the origin #196

kassambara opened this issue Apr 16, 2017 · 7 comments

Comments

@kassambara
Copy link
Owner

(User request by e-mail)

ggsurvplot follow the standard R/ggplot convention of having the axes offset from the origin (I have never understood why this is the case – since basic mathematics you always show x=y=0 as the origin). Normally I would get around this by using yaxs="i" in plot, and I believe there is a similar way with expand limits in ggplot, however when I do this, the axis disappears.

Normally it is a bit of an annoyance, but with Kaplan-Meier plots is actually quite critical – after all we want to see when survival hits y=0 – with the values offset and a large number of patients you aren’t sure if it has hit 0, or there is still someone left! Any advice would be great, and even better if the default in the package was changed at the next update, as those who would want it offset must be in a minority i.e. nobody. Also if someone isn’t fussy, they should get the more accurate version!

kassambara added a commit that referenced this issue Apr 28, 2017
@kassambara
Copy link
Owner Author

This has been fixed now:

library(survival)
library(survminer)

# Basic survival curves
fit<- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, risk.table = TRUE,
           tables.theme = theme_cleantable())

rplot09

kassambara added a commit that referenced this issue May 2, 2017
kassambara added a commit that referenced this issue May 2, 2017
@kassambara
Copy link
Owner Author

New argument axes.offset added. logical value. Default is TRUE. If FALSE, set the plot axes to start at the origin.

@ShixiangWang
Copy link

Hello, @kassambara How can I make sure the 100% in the figure ?

image

@akirosingh
Copy link

@ShixiangWang I was able to fix it by just increasing the y limits. ylim=c(0,1.01)

@ShixiangWang
Copy link

@akirosingh Thanks :)

@MBender1992
Copy link

MBender1992 commented Apr 9, 2021

Hello @kassambara,
How can I align the risk table so the number at risk for time 0 also starts at 0 and is not shifted to the right when setting axes.offset = FALSE ?

@corneliushennch
Copy link

Hello @kassambara,
How can I align the risk table so the number at risk for time 0 also starts at 0 and is not shifted to the right when setting axes.offset = FALSE ?

Hey, I ran in to the same problem. The alignment of the risk.table is completely shifted, once you use axis.offset = TRUE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants