在ggplot2中用bquote折叠副标题

亚当

我正在尝试将副标题更改为“按照 5x10^7 TCID50 处理的所有主题”,上标为 7,下标为 50。

我能够运行以下图,其中有空格(“5 x 10”):

示例图

使用以下代码:

kmcurve1 <- ggsurvplot(km_p1p2_p2dose_fit, 
              palette = c("#202960", "#8CC63E"), 
              xlab = "Time (Months)", 
              legend.labs = c("Phase 1", "Phase 2"), 
              break.time.by = 6, 
              xlim = c(0,36), 
              conf.int = FALSE, 
              pval = TRUE, 
              pval.size = 5, 
              pval.method.size = 5, 
              pval.coord = c(30,0.9), 
              pval.method.coord = c(30,1), 
              pval.method = TRUE, 
              surv.median.line = "v", 
              risk.table = "abs_pct", 
              risk.table.col = "strata", 
              surv.plot.height = 2, 
              risk.table.height = 0.24, 
              censor.shape = "|", 
              censor.size = 5, 
              font.title = 28, 
              font.x = 14, 
              font.y = 14,
              font.tickslab = 12,
              risk.table.fontsize = 3.5)

kmcurve1$plot <- kmcurve1$plot +
  labs(title = "Overall Survival for Phase 1 and Phase 2",
       subtitle = bquote(All~Subjects~as~Treated~at~5.0~x~10^7~TCID[50]),
        caption = bquote(TCID[50]~-~Median~Tissue~Culture~Infectious~Dose)) +
        theme(#text = element_text(family = "serif"), #only run for PDF output
              plot.title = element_text(size = 20), 
              plot.subtitle = element_text(size = 16), 
              plot.caption = element_text(size = 12),
              legend.text = element_text(size = 12), 
              legend.title = element_text(size = 12), 
              legend.key.size = unit(16, "points"), 
              axis.title.x = element_text(size = 14), 
              axis.title.y = element_text(size = 14),
              axis.text.x = element_text(size = 12), 
              axis.text.y = element_text(size = 12))

kmcurve1

我已经删除了研究编号以避免获得识别信息。

对于副标题,我也试过bquote(All~Subjects~as~Treated~at~5.0x10^7~TCID[50]),它给了我以下错误信息:

Error: unexpected symbol in:
"  labs(title = "Overall Survival for Phase 1 and Phase 2",
       subtitle = bquote(All~Subjects~as~Treated~at~5.0x10"

让我知道使用 KM 拟合的 reprex 来复制曲线是否有帮助。

希利亚姆

如果我正确理解您的目标,要显示“x”周围没有空格的副标题,请尝试将部分数学表达式替换为字符串“5x10”。bquote能够将数学表达式与字符串结合起来。这是您以可重复的情节呈现的副标题。

library(survminer)
library(survival)

fit<- survfit(Surv(time, status) ~ sex, data = lung)
p <- ggsurvplot(fit, data = lung)

  p$plot +
  labs(title = "Overall Survival for Phase 1 and Phase 2",
       subtitle = bquote(All~Subjects~as~Treated~at~'5x10'^7~TCID[50]),
       caption = bquote(TCID[50]~-~Median~Tissue~Culture~Infectious~Dose))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章