Torsten
Torsten

Reputation: 43

Left align text in forestplot() from forestplot package

For a paper we want to display our sensitivy data in a forestplot. For this I used the forestplot-package from R. For the plot I adopted the code provided here: https://www.r-bloggers.com/forest-plot-with-horizontal-bands/. I have now the problem that the effects in my labeltext are center-aligned. As some of the effects are negativ the text Looks quite fluttery. Although I have looked around I don't find a way to left-align the text.

Here is the code for the actual plot. I think it is a small issue but I got stock on it. Thanks for any help

forestplot(labeltext=tabletext, graph.pos=5, 
       mean=c(NA,NA,NA,NA,data$Group.difference), 
       lower=c(NA,NA,NA,NA,data$Lower), upper=c(NA,NA,NA,NA,data$Upper),
       title="Sensitivity Analyses of gait speed 3 months after Stroke", 
       xlab="<---RELAX Better---                                      ---PHYS Better--->",
       grid = TRUE,
       hrzl_lines=list("5" = gpar(lwd=1, col="black"), 
                       "9" = gpar(lwd=45, lineend="butt", columns=c(1:7), col="#99999922"),
                       "18" = gpar(lwd=45, lineend="butt", columns=c(1:7), col="#99999922"),
                       "26" = gpar(lwd=45, lineend="butt", columns=c(1:7), col="#99999922")),
       txt_gp=fpTxtGp(label=gpar(cex=1.25),
                      ticks=gpar(cex=1.1),
                      xlab=gpar(cex = 1.2),
                      title=gpar(cex = 1.8)),
       col=fpColors(box="black", lines="black", zero = "gray50"),
       zero=0, cex=0.9, lineheight = "auto", boxsize=0.5, colgap=unit(6,"mm"),
       lwd.ci=2, ci.vertices=TRUE, ci.vertices.height = 0.4)

Upvotes: 2

Views: 3801

Answers (1)

Thomas Zelniker
Thomas Zelniker

Reputation: 93

Just include:

 align = c("l", "l", "l"), # Use "l", "c", or "r" for left, center, or right aligned

Upvotes: 3

Related Questions