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

axes.offset and risk table alignment #243

Closed
dmartinffm opened this issue Jul 11, 2017 · 8 comments
Closed

axes.offset and risk table alignment #243

dmartinffm opened this issue Jul 11, 2017 · 8 comments

Comments

@dmartinffm
Copy link

Expected behavior

Risk tables should align to X axis ticks of the plot when using axes.offset=FALSE

Actual behavior

Tables are not aligned to plot

Steps to reproduce the problem

Use risk.table=TRUE and axes.offset=FALSE

session_info()

# please paste here the result of
devtools::session_info()

Session info ------------------------------------------------------------------
setting value
version R version 3.3.1 (2016-06-21)
system x86_64, darwin13.4.0
ui RStudio (1.0.136)
language (EN)
collate de_DE.UTF-8
tz Europe/Berlin
date 2017-07-11

Packages ----------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.3.2)
base * 3.3.1 2016-06-24 local
bindr 0.1 2016-11-13 cran (@0.1)
bindrcpp * 0.2 2017-06-17 cran (@0.2)
broom 0.4.2 2017-02-13 CRAN (R 3.3.2)
cmprsk 2.2-7 2014-06-17 CRAN (R 3.3.0)
colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2)
data.table 1.10.4 2017-02-01 CRAN (R 3.3.1)
datasets * 3.3.1 2016-06-24 local
devtools 1.13.2 2017-06-02 CRAN (R 3.3.2)
digest 0.6.12 2017-01-27 CRAN (R 3.3.2)
dplyr * 0.7.1 2017-06-22 cran (@0.7.1)
forcats 0.2.0 2017-01-23 CRAN (R 3.3.2)
foreign 0.8-69 2017-06-21 CRAN (R 3.3.2)
ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.3.2)
ggpubr * 0.1.4 2017-06-28 cran (@0.1.4)
glue 1.1.1 2017-06-21 cran (@1.1.1)
graphics * 3.3.1 2016-06-24 local
grDevices * 3.3.1 2016-06-24 local
grid 3.3.1 2016-06-24 local
gridExtra 2.2.1 2016-02-29 CRAN (R 3.3.0)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.0)
haven * 1.1.0 2017-07-09 CRAN (R 3.3.2)
hms 0.3 2016-11-22 CRAN (R 3.3.2)
km.ci 0.5-2 2009-08-30 CRAN (R 3.3.0)
KMsurv 0.1-5 2012-12-03 CRAN (R 3.3.0)
knitr 1.16 2017-05-18 CRAN (R 3.3.2)
lattice 0.20-35 2017-03-25 CRAN (R 3.3.2)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0)
magrittr * 1.5 2014-11-22 CRAN (R 3.3.0)
Matrix 1.2-10 2017-04-28 CRAN (R 3.3.2)
memoise 1.1.0 2017-04-21 CRAN (R 3.3.2)
methods * 3.3.1 2016-06-24 local
mnormt 1.5-5 2016-10-15 CRAN (R 3.3.0)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.0)
nlme 3.1-131 2017-02-06 CRAN (R 3.3.2)
parallel 3.3.1 2016-06-24 local
pkgconfig 2.0.1 2017-03-21 cran (@2.0.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.0)
psych 1.7.5 2017-05-03 CRAN (R 3.3.1)
purrr 0.2.2.2 2017-05-11 CRAN (R 3.3.2)
R6 2.2.2 2017-06-17 cran (@2.2.2)
Rcpp 0.12.11 2017-05-22 CRAN (R 3.3.2)
readr 1.1.1 2017-05-16 CRAN (R 3.3.2)
reshape2 1.4.2 2016-10-22 CRAN (R 3.3.0)
rlang 0.1.1 2017-05-18 CRAN (R 3.3.2)
scales 0.4.1 2016-11-09 CRAN (R 3.3.2)
splines 3.3.1 2016-06-24 local
stats * 3.3.1 2016-06-24 local
stringi 1.1.5 2017-04-07 CRAN (R 3.3.2)
stringr 1.2.0 2017-02-18 CRAN (R 3.3.2)
survival * 2.41-3 2017-04-04 CRAN (R 3.3.2)
survminer * 0.4.0.999 2017-07-11 Github (bea688c)
survMisc 0.5.4 2016-11-23 CRAN (R 3.3.2)
tibble 1.3.3 2017-05-28 CRAN (R 3.3.2)
tidyr 0.6.3 2017-05-15 CRAN (R 3.3.2)
tools 3.3.1 2016-06-24 local
utils * 3.3.1 2016-06-24 local
withr 1.0.2 2016-06-20 CRAN (R 3.3.0)
xtable 1.8-2 2016-02-05 CRAN (R 3.3.0)
zoo 1.8-0 2017-04-12 CRAN (R 3.3.2)

@kassambara
Copy link
Owner

Hi,

I'm out of office and have limited access to my e-mail. I will be able to check this on jully 17th.

Thank you

@x-ray90
Copy link

x-ray90 commented Apr 24, 2018

I'm having the same problem. I really would like to avoid using the axis offset since I find it not precicely representing the data. However with this issue I am also prevented from using risk tables (since the number at risk does not align with the breaks of the x-axis).

@x-ray90
Copy link

x-ray90 commented Jul 2, 2018

Is there maybe a hack to cancel the axis offset for the risk table? Would be great to have graph and risk table align...

@IsaSmall
Copy link

Hi,

Is this problem already solved? I'm finishing up a paper and it would be great if I could have them aligned (using axes.offset=FALSE).

Thanks

@kassambara
Copy link
Owner

Fixed now, thanks.

library(survival)
library(survminer)
data(lung)
fit <- survfit(Surv(time, status) ~sex, data = lung)
ggsurvplot(fit, risk.table = TRUE, axes.offset = FALSE,
           xlim = c(0, 1050))

rplot

kassambara added a commit that referenced this issue Jul 24, 2018
@IsaSmall
Copy link

Hi Kassambara,

Thank you for the quick response. But, it didn't work for me or maybe I am doing something wrong...

fit <- survfit(Surv(IG, Obito) ~ Tratamento, data = neos)

ggsurv<- ggsurvplot(fit, data = neos,
pval = TRUE, # Add p-value & method name
pval.method = FALSE,
pval.size = 4,
pval.coord = c(2, 0.1),
legend.title = " ",
legend.labs = c("A", "B"),
palette = "lancet",
surv.median.line = "hv",
risk.table = TRUE,
risk.table.height = 0.20,
risk.table.pos = "out",
risk.table.fontsize = 4,
cumevents = FALSE,
tables.height = 0.15,
tables.theme = theme_cleantable(),
tables.y.text = FALSE,
xlim = c(0,96),
xlab = "Follow-up (months)",
axes.offset = FALSE,
break.time.by = 12,
yslim = c(0,100),
ylab = "Overall survival",
break.y = 0.10,
font.y= c(12, "plain"),
font.x = c(12, "plain"),
font.tickslab = c(9, "plain"),
surv.scale = "percent"
)
ggsurv$table <- ggsurv$table +
theme(plot.title = element_text(size = 10, color = "black", face = "plain"))
ggsurv

image

@kassambara kassambara reopened this Jul 26, 2018
@kassambara
Copy link
Owner

You need to install the latest developmental version of survminer

@IsaSmall
Copy link

Great! Thank you very much, @kassambara!

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

4 participants