英文:
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
我们可以使用 expression
与 underline
,在这个示例中我正在给 "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"))
英文:
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"))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论