What you are describing is a frequent problem in survival analysis. The main variable of interest is continuous, but you still want a Kaplan-Meier style plot to display the main effect. Instead of artificially categorizing your continuous variable or displaying conditional effects (as the rms package does), you could use the contsurvplot R-package (written by me). It produces plots that display the counterfactual survival probabiltiy both as a function of time and the continuous covariate. More information can be found in the preprint that I recently published: https://arxiv.org/abs/2208.04644
It can be installed directly from github using:
devtools::install_github("RobinDenz1/contsurvplot")
I will give a quick example using the nafld1 dataset from the survival package. Suppose we are interested in the effect of age on the survival time. We first use a Cox model to analyze this effect:
library(contsurvplot)
library(riskRegression)
library(survival)
library(ggplot2)
library(pammtools)
using data from the survival package
data(nafld, package="survival")
taking a random sample to keep the example fast
set.seed(43)
nafld1 <- nafld1[sample(nrow(nafld1), 400), ]
fit cox-model with age
model <- coxph(Surv(futime, status) ~ age, data=nafld1, x=TRUE)
Now we want to visualize the effect for 40 to 70 year olds. We can easily create a survival area plot using the plot_surv_area function:
plot_surv_area(time="futime",
status="status",
variable="age",
data=nafld1,
model=model,
horizon=seq(40, 70, 0.5))
Or we can use a survival contour plot:
plot_surv_contour(time="futime",
status="status",
variable="age",
data=nafld1,
model=model,
horizon=seq(40, 70, 0.5))
In my opinion, both are better options than simple categorized Kaplan-Meier plots.