library(ggplot2)
# Weibull survival function
weibull_surv <- function(t, lambda, gamma) {
exp(-lambda * t^gamma)
}
time_points <- seq(0, 20, by = 1)
# Generate curves
surv_data <- data.frame(
Time = rep(time_points, 4),
Survival = c(
weibull_surv(time_points, 0.045, 1.15),
weibull_surv(time_points, 0.045 * 0.70, 1.15),
weibull_surv(time_points, 0.12, 1.05),
weibull_surv(time_points, 0.12 * 0.50, 1.05)
),
Curve = rep(c("OS - Chemo", "OS - Trastuzumab",
"PFS - Chemo", "PFS - Trastuzumab"),
each = length(time_points)),
Type = rep(c("OS", "OS", "PFS", "PFS"), each = length(time_points))
)
ggplot(surv_data, aes(x = Time, y = Survival, colour = Curve, linetype = Type)) +
geom_line(linewidth = 1.1) +
scale_colour_manual(values = c("OS - Chemo" = "#e15759",
"OS - Trastuzumab" = "#4e79a7",
"PFS - Chemo" = "#f28e2b",
"PFS - Trastuzumab" = "#59a14f")) +
scale_linetype_manual(values = c("OS" = "solid", "PFS" = "dashed")) +
labs(x = "Years", y = "Survival Probability",
title = "Trastuzumab Improves Both OS and PFS") +
theme_minimal() +
theme(legend.position = "bottom")