# construct plot
p <-
survfit2(Surv(time, status) ~ surg, df_colon) %>%
ggsurvfit() +
add_risktable() +
scale_y_continuous(limits = c(0, 1))
# build plots
built_p <- ggsurvfit_build(p, combine_plots = FALSE)
# reconstruct original figure print with risktables
patchwork::wrap_plots(
built_p[[1]],
built_p[[2]],
built_p[[3]],
ncol = 1,
heights = c(0.70, 0.15, 0.15)
)
# place plots side-by-side (plots must be built before placement with patchwork)
patchwork::wrap_plots(
ggsurvfit_build(p),
ggsurvfit_build(p),
ncol = 2
)
Run the code above in your browser using DataLab