I'm trying to save multiple plots to one pdf, typically I use:
# creating pdf from four panels
# these aren't reproducible but any ggplot will recreate error essentially
pdf(file = "Fig.1", height = 14, width = 14)
Fig.1<- grid.arrange(p1,p2,p3,p4)
print(Fig.1)
dev.off()
However, I want to use a specific font in the plots.
I have thus downloaded and installed the fontextra
package, intalled and loaded the fonts with loadfonts(device = "win")
. I then use theme(text=element_text(family="Calibri"))
within the ggplot call.
When I re-run code individual plots will look fine in R itself. I can also successfully use grid.arrange using gridExtra
to arrange them and check them within R itself. However, when I use:
pdf(file = "Fig.4.trw.pdf", height = 14, width = 14)
Fig.4.trw<- grid.arrange(p1,p2,p3,p4)
I get a bunch of errors associated to fonts:
In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x30
I've also tried to use ggsave
but that isn't working either, please help!
Thanks