使用forestplot下划线标题

huangapple go评论71阅读模式
英文:

Underline the header using forestplot

问题

我正在尝试为我使用forestplot库的forestplot()函数创建的森林图的列标题添加下划线。

这是我已经在图表中设置的部分设置的摘录。在下面的代码中,我已经将标题的字体样式从默认值“bold”更改为“plain”,在“summary=”对象的最后一行中进行了更改。不幸的是,gpar(fontface="") 似乎没有“underline”选项。

library(forestplot)
base_data %>%
  forestplot(labeltext = c(text, results),
             zero = 1,
             col = fpColors(zero = "black"),
             txt_gp = fpTxtGp(label = gpar(fontfamily = "Arial"),
                              ticks = gpar(cex = 1),
                              xlab = gpar(cex = 1),
                              summary = gpar(fontface = "plain")))

有人有任何建议吗?

英文:

I'm trying to underline my headers for my columns of my forestplot, which I've created with the forestplot() function from the library(forestplot) package.

this is a excerpt of the settings i already have with the plot. I've changed the header fontface from its default "bold" to "plain" in the last line of code below, in the 'summary=' object. Unfortunately gpar(fontface="") doesn't seem to have an "underline" option.

library(forestplot)
base_data |>
 forestplot(labeltext = c(text, results),
            zero=1,
  col = fpColors(zero="black"),
            txt_gp = fpTxtGp(label = gpar(fontfamily = "Arial"),
                             ticks=gpar(cex=1),
                             xlab=gpar(cex=1),
                             summary=gpar(fontface="plain")))

Anyone have any suggestions?

答案1

得分: 1

我们可以使用 expressionunderline,在这个示例中我正在给 "Study" 添加下划线:

library(forestplot)

# 示例数据来自该包的文档:
# https://github.com/gforge/forestplot/blob/master/vignettes/forestplot.Rmd#L65

base_data |>
  forestplot(labeltext = c(study, deaths_steroid, deaths_placebo, OR),
             clip = c(0.1, 2.5),
             xlog = TRUE) |>
  fp_add_header(study = c("", expression(underline(Study))),
                deaths_steroid = c("死亡数", "(类固醇)"),
                deaths_placebo = c("死亡数", "(安慰剂)"),
                OR = c("", "OR"))

使用forestplot下划线标题

英文:

We can use expression with underline, in this example I am underlining "Study":

library(forestplot)

# example data is from the package's vignette:
# https://github.com/gforge/forestplot/blob/master/vignettes/forestplot.Rmd#L65

base_data |>
  forestplot(labeltext = c(study, deaths_steroid, deaths_placebo, OR),
             clip = c(0.1, 2.5),
             xlog = TRUE) |>
  fp_add_header(study = c("", expression(underline(Study))),
                deaths_steroid = c("Deaths", "(steroid)"),
                deaths_placebo = c("Deaths", "(placebo)"),
                OR = c("", "OR"))

使用forestplot下划线标题

huangapple
  • 本文由 发表于 2023年7月18日 03:33:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76707591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定