kassambara / survminer

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

Default to mitre linejoin when plotting step functions #653

Open heor-robyoung opened 6 months ago

heor-robyoung commented 6 months ago

Expected behavior

ggsurvplot should use a "mitre" line join on geom_step by default, for precise marking of event times. Note that "mitre" has only been enabled as a pass-through option on geom_step recently: https://github.com/tidyverse/ggplot2/pull/5706

Actual behavior

ggsurvplot uses the default "round" linejoin, making the event time difficult to distinguish in busy plots

Steps to reproduce the problem (note that as linewidth is not passed through, it is difficult to make out at screen resolution, but the problem is clear when digitising published plots at high magnification)

library(ggplot2)
library(ggfortify)
library(survminer)

data("myeloma")

sfit <- survfit(Surv(time, event) ~ molecular_group,
                data = myeloma)

ggplot(fortify(sfit, surv.connect = TRUE),
       aes(x = time, y = surv, colour = strata))+
  geom_step(linejoin = "mitre",
            linewidth = 2)

survminer::ggsurvplot(sfit,
                      linewidth = 2,
                      linejoin = "mitre")

image image

session_info()

─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.3 (2023-03-15 ucrt)
 os       Windows 10 x64 (build 22621)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United Kingdom.utf8
 ctype    English_United Kingdom.utf8
 tz       Europe/London
 date     2024-04-25
 rstudio  2023.09.0+463 Desert Sunflower (desktop)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version date (UTC) lib source
 P abind         1.4-5   2016-07-21 [?] RSPM (R 4.2.0)
 P backports     1.4.1   2021-12-13 [?] RSPM (R 4.2.0)
 P broom         1.0.5   2023-06-09 [?] RSPM (R 4.2.0)
 P cachem        1.0.8   2023-05-01 [?] RSPM (R 4.2.0)
 P car           3.1-2   2023-03-30 [?] RSPM (R 4.2.0)
 P carData       3.0-5   2022-01-06 [?] RSPM (R 4.2.0)
 P cli           3.6.2   2023-12-11 [?] RSPM (R 4.2.0)
 P colorspace    2.1-0   2023-01-23 [?] RSPM (R 4.2.0)
 P commonmark    1.9.1   2024-01-30 [?] RSPM (R 4.2.0)
 P data.table    1.15.4  2024-03-30 [?] RSPM (R 4.2.0)
 P devtools      2.4.5   2022-10-11 [?] RSPM (R 4.2.0)
 P digest        0.6.35  2024-03-11 [?] RSPM (R 4.2.0)
 P dplyr         1.1.4   2023-11-17 [?] RSPM (R 4.2.0)
 P ellipsis      0.3.2   2021-04-29 [?] RSPM (R 4.2.0)
 P fansi         1.0.6   2023-12-08 [?] RSPM (R 4.2.0)
 P farver        2.1.1   2022-07-06 [?] RSPM (R 4.2.0)
 P fastmap       1.1.1   2023-02-24 [?] RSPM (R 4.2.0)
 P fs            1.6.3   2023-07-20 [?] RSPM (R 4.2.0)
 P generics      0.1.3   2022-07-05 [?] RSPM (R 4.2.0)
 P ggfortify   * 0.4.17  2024-04-17 [?] RSPM (R 4.2.0)
 P ggplot2     * 3.5.1   2024-04-23 [?] RSPM (R 4.2.0)
 P ggpubr      * 0.6.0   2023-02-10 [?] RSPM (R 4.2.0)
 P ggsignif      0.6.4   2022-10-13 [?] RSPM (R 4.2.0)
 P ggtext        0.1.2   2022-09-16 [?] RSPM (R 4.2.0)
 P glue          1.7.0   2024-01-09 [?] CRAN (R 4.2.3)
 P gridExtra     2.3     2017-09-09 [?] RSPM (R 4.2.0)
 P gridtext      0.1.5   2022-09-16 [?] RSPM (R 4.2.0)
 P gtable        0.3.5   2024-04-22 [?] RSPM (R 4.2.0)
 P htmltools     0.5.8.1 2024-04-04 [?] RSPM (R 4.2.0)
 P htmlwidgets   1.6.4   2023-12-06 [?] RSPM (R 4.2.0)
 P httpuv        1.6.15  2024-03-26 [?] RSPM (R 4.2.0)
 P km.ci         0.5-6   2022-04-06 [?] RSPM (R 4.2.0)
 P KMsurv        0.1-5   2012-12-03 [?] RSPM (R 4.2.0)
 P knitr         1.46    2024-04-06 [?] RSPM (R 4.2.0)
 P labeling      0.4.3   2023-08-29 [?] RSPM (R 4.2.0)
 P later         1.3.2   2023-12-06 [?] RSPM (R 4.2.0)
 P lattice       0.20-45 2021-09-22 [?] CRAN (R 4.2.3)
 P lifecycle     1.0.4   2023-11-07 [?] RSPM (R 4.2.0)
 P magrittr      2.0.3   2022-03-30 [?] RSPM (R 4.2.0)
 P markdown      1.12    2023-12-06 [?] RSPM (R 4.2.0)
 P Matrix        1.5-3   2022-11-11 [?] CRAN (R 4.2.3)
 P memoise       2.0.1   2021-11-26 [?] RSPM (R 4.2.0)
 P mime          0.12    2021-09-28 [?] RSPM (R 4.2.0)
 P miniUI        0.1.1.1 2018-05-18 [?] RSPM (R 4.2.0)
 P munsell       0.5.1   2024-04-01 [?] RSPM (R 4.2.0)
 P pillar        1.9.0   2023-03-22 [?] RSPM (R 4.2.0)
 P pkgbuild      1.4.4   2024-03-17 [?] RSPM (R 4.2.0)
 P pkgconfig     2.0.3   2019-09-22 [?] RSPM (R 4.2.0)
 P pkgload       1.3.4   2024-01-16 [?] RSPM (R 4.2.0)
 P profvis       0.3.8   2023-05-02 [?] RSPM (R 4.2.0)
 P promises      1.3.0   2024-04-05 [?] RSPM (R 4.2.0)
 P purrr         1.0.2   2023-08-10 [?] RSPM (R 4.2.0)
 P R6            2.5.1   2021-08-19 [?] RSPM (R 4.2.0)
 P Rcpp          1.0.12  2024-01-09 [?] CRAN (R 4.2.3)
 P remotes       2.5.0   2024-03-17 [?] RSPM (R 4.2.0)
   renv          1.0.3   2023-09-19 [1] CRAN (R 4.2.3)
 P rlang         1.1.3   2024-01-10 [?] CRAN (R 4.2.3)
 P rstatix       0.7.2   2023-02-01 [?] RSPM (R 4.2.0)
 P scales        1.3.0   2023-11-28 [?] RSPM (R 4.2.0)
 P sessioninfo   1.2.2   2021-12-06 [?] RSPM (R 4.2.0)
 P shiny         1.8.1.1 2024-04-02 [?] RSPM (R 4.2.0)
 P stringi       1.8.3   2023-12-11 [?] RSPM (R 4.2.0)
 P stringr       1.5.1   2023-11-14 [?] RSPM (R 4.2.0)
 P survival    * 3.5-3   2023-02-12 [?] CRAN (R 4.2.3)
 P survminer   * 0.4.9   2021-03-09 [?] RSPM (R 4.2.0)
 P survMisc      0.5.6   2022-04-07 [?] RSPM (R 4.2.0)
 P tibble        3.2.1   2023-03-20 [?] RSPM (R 4.2.0)
 P tidyr         1.3.1   2024-01-24 [?] CRAN (R 4.2.3)
 P tidyselect    1.2.1   2024-03-11 [?] RSPM (R 4.2.0)
 P urlchecker    1.0.1   2021-11-30 [?] RSPM (R 4.2.0)
 P usethis       2.2.3   2024-02-19 [?] RSPM (R 4.2.0)
 P utf8          1.2.4   2023-10-22 [?] RSPM (R 4.2.0)
 P vctrs         0.6.5   2023-12-01 [?] RSPM (R 4.2.0)
 P withr         3.0.0   2024-01-16 [?] CRAN (R 4.2.3)
 P xfun          0.43    2024-03-25 [?] RSPM (R 4.2.0)
 P xml2          1.3.6   2023-12-04 [?] RSPM (R 4.2.0)
 P xtable        1.8-4   2019-04-21 [?] RSPM (R 4.2.0)
 P zoo           1.8-12  2023-04-13 [?] RSPM (R 4.2.0)

 [1] C:/Users/rob.young/_Github_Repos/survminer_test/renv/library/R-4.2/x86_64-w64-mingw32
 [2] C:/Users/rob.young/AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/19d6eec0

 P ── Loaded and on-disk path mismatch.