It would be nice to see all the groups at 100% survival.
Actual behavior
All the surviving groups overlap eachother at 100%
Steps to reproduce the problem
Suggested change:
# example survival fit, from docs
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)
# Basic survival curves
gg <- ggsurvplot(fit, data = lung)
if(nudge){
# this mess puls apart the ggplot/ggsuv object and manually manipulates the values to avoid overlap at the 100% survival line.
# Jitter ammount is computed using the numeric factor level of the color used for grouping. Not elegant, but it works in my limited testing.
gg_decon <- ggplot_build(gg$plot)
ng <- length(unique(gg_decon$data[[1]]$colour))
# modify the lines
gg_decon$data[[1]] <- gg_decon$data[[1]] %>%
mutate(y=ifelse(y==1, 1 + (.01*as.numeric(as.factor(colour))), y))
# modify the censor point
gg_decon$data[[3]] <- gg_decon$data[[3]] %>%
mutate(y=ifelse(y==1, 1 + (.01*as.numeric(as.factor(colour))), y))
# from https://ggplot2-book.org/internals.html
gtable <- ggplot_gtable(gg_decon)
grid::grid.newpage()
grid::grid.draw(gtable)
return(invisible(gtable))
} else{
return(gg)
}
Results
Here I am showing my data, as it has more groups than the lung data
Old Version:
This isn't a bug, but a suggested enhancement. Prism does something similar they call nudging: https://www.graphpad.com/guides/prism/latest/user-guide/using_change_plotting_order_survival_2.htm
Expected behavior
It would be nice to see all the groups at 100% survival.
Actual behavior
All the surviving groups overlap eachother at 100%
Steps to reproduce the problem
Suggested change:
Results
Here I am showing my data, as it has more groups than the lung data Old Version:
Nudged Version:
session_info()