Changing the font size of x-axis labels in forestplot R function

Viewed 4991

I am generating a forest plot in R using the following code:

forestplot(livertabletext, 
            liverdata,new_page = TRUE,
            is.summary=c(TRUE,rep(FALSE,3),TRUE),
            clip=c(0.1,2.0), 
            xlog=TRUE, 
            graph.pos=3,
            boxsize=0.1,
            xticks=c(0.2,0.5,1,2,5,7),
            txt_gp = fpTxtGp(cex=0.75),
            col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

The fpTxtGp(cex=0.75) parameter only changes the font size of the other elements of the graph, not the x-axis. I tried using a smaller font size so that relatively, it is closer to the default x-axis font size, but that made the x-axis font even smaller.

I've searched for a while now in the documentation with no luck.

1 Answers

You can separately change the font size of elements by setting txt_gp = fpTxtGp(ticks=gpar(cex=4)). The available options are: label, summary, xlab, title, ticks and legend.

Here is an example of increasing the font size of X axis ticks:

ask <- par(ask=TRUE)

row_names <- list(list("test = 1", expression(test >= 2)))
test_data <- data.frame(coef=c(1.59, 1.24),
                    low=c(1.4, 0.78),
                    high=c(1.8, 1.55))
forestplot(row_names,
       test_data$coef,
       test_data$low,
       test_data$high,
       txt_gp = fpTxtGp(ticks=gpar(cex=4)),
       xlab = "X axis")
Related