Text and symbol size in multi-panel figures in R

In R, there are a couple of packages that allow you to create multi-panel figures (see examples here and here), but, of course, you can also make multi-panel figures in the base package*. Below I provide a simple example for creating a multi-panel figure in the R base package with the focus on making the text and symbols the same size in all of your figures, which is a desirable trait for a set of figures that will appear in the same manuscript.

The mfrow argument of the par( ) function determines the arrangement of the plots in the graphics device by specifying the number of rows and columns and the order that the graphics device is filled, i.e., by row (use mfcol to fill by columns). Below is example code and the figure that is produced from the code.

Because the graphics device holds many plots, R ‘automatically’ reduces the size of the text and symbols. From the R documentation (enter ?par in the R console), we find that “In a layout with exactly two rows and columns the base value of “cex” is reduced by a factor of 0.83: if there are three or more of either rows or columns, the reduction factor is 0.66.” Thus, the size of the text and symbols in the figure above have been reduced by 66%. Below is an example with exactly two rows and columns to demonstrate the 83% reduction.

And, finally, an example without any reduction in the size of text and symbols.

To keep the text and symbol size the same across all the figures, we need to adjust the cex argument to account for the default adjustments made by mfrow. As an example, we will reduce the text/symbol size to match the 3×2 panel figure. However, when you know the adjustment factor of mfrow, you can adjust the size to match a figure with any number of panels.

We know from the documentation that a 2×2 figure involves a reduction of 83% relative to the default. We need to reduce the size of text/symbols by another 79.5% to achieve the same reduction as in the 3×2 figure (0.83*0.795=0.66), which is applied to the numbers on the axis (cex.axis), axis labels (cex.lab), and symbols (cex).

A figure that has only 1 row has not been reduced by mfrow and, thus, should be reduced by 66% to match the reduction in the 3×2 figure.

The figures in this post involve the default spacing produced by mfrow. In another post, I show which graphical arguments to change to make more attractive multi-panel figures with mfrow.

* Other options for multi-panel figures in the R base package include layout( ) and split.screen( ).

The following two tabs change content below.

Latest posts by Travis Hinkelman (see all)

3 thoughts on “Text and symbol size in multi-panel figures in R

  1. Pingback: Spacing of panel figures in R | Datavore Consulting | Blog

  2. Pingback: Late to the ggplot2 party | Datavore Consulting, LLC

Leave a Reply