otwtm
otwtm

Reputation: 1999

Produce empty Plot with ggsurvplot

Is it possible to produce an empty plot with survminer::ggsurvplot?

Here is an example. Say, dependent on the number of groups, I want to create a ggsurvplot. Figure 1 shows an example with 2 groups. If there are no groups, the desired outcome would be Figure 2 (here created by Paint).

library(survival)
library(survminer)

set.seed(123)
df=data.frame(gender=c(rep("group1", 10), rep("group2", 10)), value=c(rnorm(10,mean = 2), rnorm(10,mean = 3)))
fit = surv_fit(Surv(value) ~ gender, data = df)
p = ggsurvplot(fit, data = df,  surv.median.line = "none") 

Figure 1

enter image description here

Upvotes: 2

Views: 355

Answers (1)

jay.sf
jay.sf

Reputation: 72623

Be a clever fox and set colors, i.e. palette= to white.

ggsurvplot(fit, data=df, surv.median.line="none", palette=rep("white", 2), legend="none") 

enter image description here

Upvotes: 2

Related Questions