Underline the header using forestplot

114 Views Asked by At

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

There are 1 best solutions below

1
zx8754 On BEST ANSWER

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"))

enter image description here