ggplot2中的特定字体未保存为pdf错误

时间:2019-07-09 11:59:23

标签: r ggplot2 extrafont

我试图将多个图保存到一个pdf中,通常我使用:

# 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()

但是,我想在绘图中使用特定的字体。

因此,我已经下载并安装了fontextra软件包,并用loadfonts(device = "win")装入了字体。然后,我在ggplot调用中使用theme(text=element_text(family="Calibri"))。 当我重新运行代码时,单个图在R本身中看起来不错。我也可以使用gridExtra成功地使用grid.arrange来排列它们并在R本身中对其进行检查。但是,当我使用时:

pdf(file = "Fig.4.trw.pdf", height = 14, width = 14)
Fig.4.trw<- grid.arrange(p1,p2,p3,p4)

我遇到了一堆与字体有关的错误:

In grid.Call(C_textBounds, as.graphicsAnnot(x$label),  ... :
font width unknown for character 0x30

我也尝试过使用ggsave,但是那也不起作用,请帮忙!

谢谢

0 个答案:

没有答案