首页 > 解决方案 > 在 ggsurvplot 上更改主题 - 错误:不知道如何将 ggtheme 添加到绘图中

问题描述

我在 surv_rate 中有必要列的数据。这就是我正在运行的,它基于以下示例:http: //www.sthda.com/english/rpkgs/survminer/reference/ggsurvplot.html

fit2 <- survfit(Surv(YearsToStatus, VitalStatus) ~ PR_statusIndex + HER2_statusIndex + ER_statusIndex,
                data = surv_rate)

ggsurv <- ggsurvplot(fit2, data = surv_rate, ggtheme = theme_bw)

我收到此错误:

Error: Don't know how to add ggtheme to a plot

我尝试这样做的原因是ggsurv图中没有显示网格线。

提前感谢您可以给我的任何帮助,另外作为参考,我对 R 相当陌生。

标签: rggplot2

解决方案


主题必须像在ggplot2中那样编写为函数,因此主题名称需要以一对括号结尾。

ggtheme = theme_bw()

推荐阅读