【发布时间】:2021-11-10 15:23:26
【问题描述】:
我为我的数据绘制了 Kaplan Meier 曲线,该曲线适用于 6 种不同的治疗方法,即:
- 100低
- 30 低
- 15低
- 100高
- 30高
- 15高
我希望我的图例按照我上面提到的顺序排列,但是当我绘制它时,它会给出图片中所附的图例。
我使用的代码如下。有人可以帮我解决如何重新排列图例表的顺序吗?
#Kaplan-Meier curves to plot the result
ru <- survfit(Surv(Tf,fat==1) ~ Treatments, data = fat)
uu <- ggsurv(ru, CI = "def", plot.cens = TRUE, surv.col = c(1,1,2,2,3,3),
cens.col = 1, lty.est = c(1,1,1,5,5,5), size.est = 1.05, cens.shape = 12, cens.size = 3,
back.white = FALSE, xlab = "Time (seconds)", ylab = "Ratio of fish remaining", main = "Kaplan-Meier Curves")
uu1 <- uu + theme_gray(base_size=13) + theme(legend.position = "right") + theme(legend.title = element_text(face = "bold")) +
theme(plot.title = element_text(face = "bold")) + theme(axis.title = element_text(size = 15, face = "bold")) +
theme(axis.ticks = element_line(size = 1)) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) +
scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) + theme(axis.text = element_text(size = 14)) +
theme(legend.text = element_text(size = 12))
windows()
(uu1)
这里的“Tf”是我的数据中的时间,它在数据框“fat”中
非常感谢您。
【问题讨论】:
标签: r graph legend survival-analysis legend-properties