Hi all, this is the first time I am making a forest plot. I have some questions. I hope some of you can help.
- I am trying to add horizontal grid to a forest plot as a guide to read the OR and its 95% CI provided on the right. How do I do this?
- Is there a way I can format zero line (line type and line width)?
- Can I add an additional vertical line at 0?
The code is as follows:
step_cluster_obese <-
structure(list(
OR = c(NA, NA, 0.38, 1.09, 1.41, 2.05, 2.05, 2.41, 3.15),
lower = c(NA, NA, 0.15, 0.50, 0.82, 1.15, 1.30, 1.39, 1.69),
upper = c(NA, NA, 0.93, 2.38, 2.40, 3.63, 3.21, 4.19, 5.87)),
.Names = c("OR", "lower", "upper"),
row.names = c(NA, -11L),
class = "data.frame")
tabletext<-cbind(
c("", "Factor", "a", "b", "c", "d", "e", "f", "g"),
c("", "OR (95% CI)", "0.38 (0.15, 0.93)", "1.09 (0.50, 2.38)", "1.41 (0.82, 2.40)", "2.05 (1.15, 3.63)", "2.05 (1.30, 3.21)", "2.41 (1.39, 4.19)", "3.15 (1.69, 5.87)"))
forestplot(tabletext,
graph.pos = 2, step_cluster_obese, new_page = TRUE, boxsize = .15,
is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
clip=c(0.1,6.5),
xlog=FALSE,
zero = 1,
col=fpColors(box = "black", lines = "black", summary = "black", zero = "grey", text = "black", axes = "black", hrz_lines = "black"),
vertices = TRUE,
xlab="Odds Ratio",
xticks = c(0, 1, 2, 3, 4, 5, 6),
lwd.zero = 0,
txt_gp = fpTxtGp(label = list(gpar(fontfamily = "sans", cex = 1.5),
gpar(fontfamily = "")),
ticks = gpar(fontfamily = "", cex=1.5),
xlab = gpar(fontfamily = "sans", cex = 1.5)))