Skip to content

Risk Table Not Synchronized with Custom X-Axis Breaks in ggsurvplot #695

@AjayKumar-O

Description

@AjayKumar-O

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions