I am trying to prepare a forest plot for summarizing patient survival outcomes in multiple cohorts using the forestplot
package in R. The plot comes out fine but I am struggling to increase the size of the numbers displayed in the plot keeping everything else same.
Here’s the data:
> dput(tabletext)
structure(c("Cohort", "ABCDE", " ABCDE High", " ABCDE Low",
NA, "ABCDE + ABC", " ABCDE Low + ABC High", " ABCDE High + ABC Low",
NA, "ABCDE Low + ABC High", " ABCDEF High", " ABCDEF Low",
NA, "ABCDE Low + ABC High", " ABCDEFGHI High", " ABCDEFGHI low",
NA, "ABCDE Low + ABC High", " ABCDEF High", " ABCDEF Low",
NA, "ABCDE Low + ABC High + ABCDEF High", " ABCDEFGHI High",
" ABCDEFGHI Low", NA, "ABCDE Low + ABC High + ABCDEF High",
" ABCDEF High", " ABCDEF Low", NA, "Patients", NA, "53",
"196", NA, NA, "118", "38", NA, NA, "92", "26", NA, NA, "27",
"91", NA, NA, "58", "60", NA, NA, "14", "78", NA, NA, "47", "45",
NA, "HR", NA, "0.49", "2.04", NA, NA, "2.77", "0.36", NA, NA,
"2.03", "0.49", NA, NA, "1.65", "0.6", NA, NA, "0.73", "1.37",
NA, NA, "2.39", "0.42", NA, NA, "0.69", "1.45", NA, "Median survivaln(Months)",
NA, "26", "11.53", NA, NA, "10.17", "34.07", NA, NA, "9.57",
"15.13", NA, NA, "8.67", "11.47", NA, NA, "12.6", "8.93", NA,
NA, "5.38", "9.8", NA, NA, "11.58", "8.33", NA, "Regressionncoefficient (B)",
NA, "-0.71", "0.71", NA, NA, "1.02", "-1.02", NA, NA, "0.71",
"-0.71", NA, NA, "0.5", "-0.5", NA, NA, "-0.32", "0.32", NA,
NA, "0.87", "-0.87", NA, NA, "-0.37", "0.37", NA, "95% CIn(Low)",
NA, "0.34", "1.4", NA, NA, "1.74", "0.23", NA, NA, "1.2", "0.29",
NA, NA, "1.05", "0.38", NA, NA, "0.49", "0.92", NA, NA, "1.32",
"0.23", NA, NA, "0.44", "0.93", NA, "95% CIn(High)", NA, "0.72",
"2.97", NA, NA, "4.41", "0.58", NA, NA, "3.44", "0.83", NA, NA,
"2.61", "0.96", NA, NA, "1.08", "2.04", NA, NA, "4.33", "0.76",
NA, NA, "1.07", "2.26", NA, "p-value", NA, "0.00", NA, NA, NA,
"0.00", NA, NA, NA, "0.01", NA, NA, NA, "0.03", NA, NA, NA, "0.12",
NA, NA, NA, "0.00", NA, NA, NA, "0.09", NA, NA), dim = c(29L,
8L))
And here’s what I have tried so far:
library(forestplot)
jpeg(filename = "./Forestplot.jpg",
units = "in",
width = 45,
height = 32,
res = 600)
forestplot(labeltext = tabletext,
graph.pos = 3,
mean = c(NA, data$HR),
lower = c(NA, data$CI_Low),
upper = c(NA, data$CI_High),
hrzl_lines = list("1" = gpar(lwd = 1,
col = "#99999922"),
"4" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"8" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"12" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"16" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"20" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"24" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922"),
"28" = gpar(lwd = 200,
lineend = "butt",
columns = c(2:9),
col = "#99999922")),
txt_gp = fpTxtGp(label = gpar(cex = 3.5,
fontface = "bold"),
summary = gpar(cex = 5,
fontface = "bold"),
ticks = gpar(cex = 3.5,
fontface = "bold"),
xlab = gpar(cex = 3.5,
fontface = "bold")),
col = fpColors(box = "black",
lines = "black",
zero = "gray50"),
xticks = xticks,
zero = 1,
lineheight = "auto",
boxsize = 0.2,
colgap = unit(6, "mm"),
lwd.ci = 3,
lwd.zero = 5,
lwd.xaxis = 5,
ci.vertices = TRUE,
ci.vertices.height = 0.4,
grid = gpar(lwd = 0.4,
col = "black"))
dev.off()
which gives me this:
I would like to increase the size of all the numbers in the plot including the x-axis labels without changing the size of the row and column labels. Changing cex
inside gpar()
changes the size of both numbers and the row/column labels. Please help.