【发布时间】:2020-07-30 17:05:41
【问题描述】:
我正在尝试使用一些参数生存估计来绘制 KM。我必须保持情节黑白,所以我无法对线条进行颜色编码,但是,当我在geom_line 的aes 函数中从color=key 更改为linetype=key 时,我得到两个标题为“ 1”和“Strata”,如下图所示。我还想知道是否可以将 KM 的颜色更改为黑色,置信区间更改为灰色。
treatment <- data.frame(
treatment = c(1, 1, 1, 1, 1, 1),
t = c(5.525, 1.9493, 4.9473, 5.9466, 1.5797, 0.5038),
event = c(1, 1, 1, 0, 1, 1)
)
tempsurv1 <- c(1.0000000, 0.9129731, 0.8337045, 0.7614860, 0.6956758, 0.6356917, 0.50, 0.43, 0.37)
tempsurv2 <- c(1.0000000, 0.9324888, 0.8671987, 0.8042297, 0.7436717, 0.6856045, 0.6300962, 0.5772029, 0.5269681)
x<- c(0:8)
temp <- data.frame(x, tempsurv1, tempsurv2)
temp<- temp %>%
gather(key, value, -c(x))
f2 <- survfit(Surv(t, event)~1, data=treatment)
f2 <- ggsurvplot(f2, legend="right")
f2 <- f2$plot + geom_line(data = temp, aes(x=x, y=value, group=key, linetype=key))+
theme(legend.position="bottom");f2
【问题讨论】:
-
是的,有可能。您需要给
color和linetype标度相同的name。我无法运行你的代码,因为你没有给我们control数据框。 -
对不起,数据是用来治疗的,我现在已经编辑过了
标签: r ggplot2 survival-analysis