-
Notifications
You must be signed in to change notification settings - Fork 169
Description
When using ggsurvplot to create a survival plot, I want to display custom x-axis breaks (e.g., weeks 0, 3, 7, 12, 24, 52) using scale_x_continuous(breaks = ...). While the plot updates correctly, the risk table below only displays values for the default or break.time.by intervals, not for my custom breaks. This causes the risk table and plot to be misaligned.
library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p <- ggsurvplot(
fit,
data = lung,
risk.table = TRUE
)
# Custom breaks for x-axis
p$plot <- p$plot + scale_x_continuous(breaks = c(0, 3, 7, 12, 24, 52))
p
The risk table does not update to show values at the custom breaks.
Expected Behavior:
The risk table should display the number at risk at the same custom breaks as the main plot.
Current Behavior:
The risk table only shows values for the default or break.time.by intervals, not for custom breaks set via scale_x_continuous.
Additional Context:
This feature would be very helpful for clinical trial reporting, where specific time points are required.