{forestmodel} How do I change the font size of forest plot?

459 Views Asked by At

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

There are 0 best solutions below