0

I have created a forest plot (using forest_model from the forestmodel package) in R based off a cox model. Everything is working perfectly except the font size. I would like to increase the font size of the predictor, factor level, confidence interval values, and p-value - everything but the actual plotted confidence interval. I formatted the plot by creating a variable that is equal to a list of code. However, changing parameters in this list of code or the forest_model function itself has not changed fontsizes at all. The code is below along with an image of part of the forest plot.

CODE:

panels <- list(
 list(width = 0.01),
 list(width = 0.1, display = ~variable, fontface = "bold", heading = "Predictor"),
 list(width = 0.03),
 list(width = 0.1, display = ~level), 
 list(width = 0.01),
 list(width = 0.12, display = ~ ifelse(reference, "Reference", sprintf(
  "%0.2f (%0.2f, %0.2f)",
 trans(estimate), trans(conf.low), trans(conf.high)
 )), display_na = NA), 
 list(width = 0.05),
 list(
  width = 0.03,
  display = ~ ifelse(reference, "", format.pval(p.value, digits = 3, eps = 0.001)),
  display_na = NA, hjust = 1, heading = "P-Value"
 ), 
 list(width = 0.09), 
 list(width = 0.03, item = "vline", hjust = 0.5), 
 list(width = 0.09),
 list(
  width = 0.55, item = "forest", hjust = 0.5, heading = "Hazard ratio", linetype = "dashed",
  line_x = 0
 ),
 list(width = 0.1))

forest_model(model,
         factor_separate_line = TRUE,
         theme = theme_forest(),
         format_options = forest_model_format_options(text_size = 9, point_size = 1.5, banded       = TRUE),
         exclude_infinite_cis = TRUE,
         panels
         )

PLOT: enter image description here

Things I have already tried:

  1. changing text_size in the forest_model_format_options
  2. Adding a "heading = element_text(size = YOUR_FONT_SIZE, face = "bold")" after heading = "NAME"
  3. Same as 2 but with "theme(heading = element_text(size = YOUR_FONT_SIZE, face = "bold"))"
  4. Same as 2 but with "heading = textGrob("Predictor", gp = gpar(fontsize = YOUR_FONT_SIZE"
I_O
  • 4,983
  • 2
  • 2
  • 15
  • Perhaps a typo in the code? This works, at least with a simple linear model: `forest_model(..., format_options = forest_model_format_options(text_size = 15))`. You might get a warning for excessive font size, though. – I_O Aug 17 '23 at 14:46
  • 1
    Double-checked and I don't think there is a typo. I ended up just changing some other settings around and it inherently made the font bigger. Thank you for helping out though! – Bob Johnson Aug 17 '23 at 17:28
  • Glad it worked out! If you think you nailed the bug, consider posting it as an answer to your question and accepting it (that way the ticket is marked as resolved and future users can benefit from your solution). – I_O Aug 17 '23 at 20:20

0 Answers0