0

I am using the grid.arrange function to arrange a set of 4 plots and add a title to them. I would like to export the result as a pdf but whenever I do so, the font of the title (although not the font used in the plots themselves) changes. Is there some way to avoid this? The code is as follows

grid.arrange(
  eeplot,
  ueplot,
  euplot,
  uuplot,
  nrow = 2,
  top=textGrob("Worker Households", gp=gpar(fontsize=20,font=6))
)

In the viewer everything looks fine

enter image description here

but when I export the plot to pdf the result is this

enter image description here

As can be seen, the font of the title (but not that of the tick labels of the plots themselves) has changed.

EDIT: When I export individual plots made in ggplot2 to pdf, I do not run into this issue. It only occurs when using grid.arrange

SDR91
  • 23
  • 1
  • 1
  • 4
  • Welcome to SO. If you would consider making this a reproducible example, e.g. creating plots with an inbuilt data set, you are much more likely to get help – tjebo Jan 22 '20 at 17:21
  • gridextra likely has different defaults for devices. this thread might help: https://stackoverflow.com/questions/14726078/changing-title-in-multiplot-ggplot2-using-grid-arrange/14726338 or use the `patchwork` package instead – tjebo Jan 22 '20 at 17:24

1 Answers1

0

Ok so it turns out that there is a simple fix to this.

Replacing

top=textGrob("Worker Households", gp=gpar(fontsize=20,font=6))

with

top=textGrob("Worker Households", gp=gpar(fontsize=20,fontfamily="serif"))

solves the issue.

SDR91
  • 23
  • 1
  • 1
  • 4