0

我正在尝试将多个图保存到一个 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")。然后我theme(text=element_text(family="Calibri"))在 ggplot 调用中使用。当我重新运行代码时,单个图在 R 本身中看起来会很好。我也可以成功地使用 grid.arrangegridExtra来排列它们并在 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但是还是不行,求大神帮忙!

谢谢

4

0 回答 0