1

我正在生成要在演示文稿中使用的生存曲线,理想情况下我想自定义 p 值文本的颜色。有可能这样做吗?我用示例数据做了一个例子,向你展示我到目前为止所做的事情。剩下的就是 #5A6469 的 p 值文本的颜色,但我已经尝试了几乎所有选项,并且它始终保持黑色!谢谢您的帮助。

library(tidyverse)
library(survival)
library(survminer)

# theme using custom colour palette and with transparent background because the slides are grey
theme_kcl <- theme_classic() + theme(plot.title = element_text(colour = "#0A2D50", size = 16, hjust = 0.5), axis.title = element_text(colour = "#0A2D50", size = 14), axis.title.x = element_text(margin = margin(t = 10, r = 0, b = 0, l = 0)), axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)), axis.text = element_text(colour = "#5A6469", size = 12), legend.text = element_text(colour = "#5A6469", size = 12)) + theme(axis.ticks.x = element_line(colour = "#5A6469"), axis.ticks.y = element_line(colour = "#5A6469"), axis.line = element_line(colour = "#0A2D50")) + theme(panel.background = element_rect(fill = "transparent", colour = NA), plot.background = element_rect(fill = "transparent", colour = NA), legend.background = element_rect(fill = "transparent", colour = NA))

# Fit example data
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# Draw survival curves
ggsurvplot(fit, palette = c("#C83296", "#009EA0"), pval = TRUE, legend = c(0.84, 0.8), legend.title = "", ggtheme = theme_kcl)
4

1 回答 1

1

是的。

首先将您的情节存储在j

j <- ggsurvplot(fit, palette = c("#C83296", "#009EA0"), pval = FALSE, legend = c(0.84, 0.8), legend.title = "", ggtheme = theme_kcl)

pval=FALSE当您要手动添加 p 值文本时,我进行了更改。

如果您需要执行对数秩检验来估计您的 p 值,只需键入

survdiff(Surv(time, status) ~ sex, data = lung)

然后

j$plot <- j$plot +
     annotate("text", x = 10, y = 15, label = "P-value", cex=3.3, col="darkgrey", vjust=0, hjust = 1.1, fontface=2)

j

只需更改 (x,y) 坐标即可。根据需要编辑或设计文本。

于 2020-01-23T17:44:37.880 回答