改变 ggsurvplot 中自定义表格的美观?

问题描述 投票:0回答:1

我使用下面的代码向 R 中的 ggsurvplot 添加一个报告中位生存期的自定义表。正如你所看到的,表格显示为灰色,有点像 ggplot 中的them_gray()主题。如何改变桌子的外观?我想要一张干净的白色桌子。

library(survival)
library(survminer)
library(ggpp)

# Load the lung cancer survival data
lung <- lung


surv_object <- Surv(lung$time, lung$status)
survfitobj <- survfit(surv_object ~ lung$sex)

km_plot <- ggsurvplot(survfitobj, data = lung)

# Add custom table 

median_df <- as.data.frame(surv_median(survfitobj))


km_plot$plot <- km_plot$plot + ggpp::annotate(geom = "table", x = max(km_plot$data.survplot$time), y = 1.0, label = list(median_df))
km_plot

r ggplot2 survival-analysis
1个回答
0
投票

你可以尝试例如

km_plot$plot <- km_plot$plot + ggpp::annotate(geom = "table", 
                                              x = max(km_plot$data.survplot$time), 
                                              table.theme = ttheme_gtbw, 
                                              y = 1.0, 
                                              label = list(median_df))

或者

km_plot$plot <- km_plot$plot + ggpp::annotate(geom = "table", 
                                              x = max(km_plot$data.survplot$time), 
                                              table.theme = ttheme_gtbw(colhead = list(bg_params = list(fill = "white"))), 
                                              y = 1.0, 
                                              label = list(median_df))

这就是您要找的吗?

© www.soinside.com 2019 - 2024. All rights reserved.