更改标题"数字风险"幸存者的大小

时间:2017-09-21 22:51:21

标签: r ggplot2

我正在使用幸存者包,我想更改"数字的字体大小"风险表的标题。尺寸太大了。

library(survminer)
p<- ggsurvplot(fit, data = final,
                  size = 0.8, 
                  censor= FALSE, 
                  font.main = 10,
                  #font.x = 10,
                  #font.y =10,

                  legend = c (0.25,0.2), 
                  legend.title = "number", 
                  legend.labs = c ("0", "1","2","3","4","5",">=6"),

                  risk.table = TRUE, risk.table.y.col = "strata", 
                  risk.table.height = 0.3,
                  fontsize =2.5, 

                  xlim = c(0, 4), 
                  xlab = "Time in years",
                  ylab = "Treatment failure-free survival", 
                  surv.scale="percent",
                  break.time.by=1,
                  tables.theme = theme_cleantable())
p$table <-   p$table + 
  theme(
    axis.ticks.y = element_blank()#removes the axis on the risk table
  )
p$plot <- p$plot + theme(legend.key.height = unit(0.58, "line")) 
ggsave(file = "ggsurv.p.tiff", print(p)) 

2 个答案:

答案 0 :(得分:2)

更改默认主题。默认主题为theme_survminer(),您必须在其中更改参数font.main,例如theme_survminer(font.main = 20)

使用默认survminer数据和代码生成绘图:

library(survminer)
require("survival")
fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, risk.table = TRUE)

enter image description here

字体大小已更改(font.main)至20

ggsurvplot(fit, data = lung, risk.table = TRUE, 
    tables.theme = theme_survminer(font.main = 20)) + 
    ggtitle("FOO")

enter image description here

答案 1 :(得分:0)

@PoGibas我发现我可以使用theme_cleantable并使用此代码来更改“有风险的数字”标题的大小:

plot$table + theme(plot.title = element_text(size=12))