R ggsurvplot固定比率

时间:2017-11-15 18:39:04

标签: r plot

我正在准备提交的最后一块情节,但无法确定最后的事情。我想要做的是使情节平方并使风险表符合它的大小。

我正在使用此代码  ggsurvplot(survfit(Surv(time,event) ~ "(hidden)"), risk.table = T, legend.labs = c("(hidden)","(hidden)"), pval = T, xlab = "Days", ylab= "Cum Survival", xlim = c(0,1000), break.x.by = c(200), surv.plot.height = 2,ggtheme = theme(aspect.ratio = 1))我的生存情节。 enter image description here

但是得到的是方形图而且是方形风险表。关于如何使代码不适用于风险表的任何想法?

此致

1 个答案:

答案 0 :(得分:1)

要修复尴尬的宽高比,可以在tables.theme的调用中指定ggsurvplot。例如:

library(survminer)
library(survival)

ggsurvplot(survfit(Surv(time, status)~ sex, data = lung), risk.table = T,
           legend.labs = c("M" ,"F"),
           pval = T,
           xlab = "Days",
           ylab= "Cum Survival",
           xlim = c(0,1000),
           break.x.by = c(200),
           surv.plot.height = 2,
           ggtheme = theme(aspect.ratio = 1),
           tables.theme =  theme(aspect.ratio = 0.2))

enter image description here