我正在尝试使用一种字体,ggplot
因为我只能通过extrafont
包装。然后当我想使用cowplot
包组合多个图时,我总是会出现大量的错误:
46: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x65
47: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x63
48: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x69
49: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x65
50: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font width unknown for character 0x73
请注意,该包确实会产生输出(即并排的绘图),但错误消息与我有关。
到目前为止我尝试了什么:
- 使用安装字体
extrafont::font_install()
- 使用加载字体
extrafont::loadfonts()
我已经安装了extrafont
。extrafontdb
cowplot
这是我的使用示例:
library(tidyverse)
library(extrafont)
library(cowplot)
library(palmerpenguins)
data(penguins)
penguins %>%
select(year, flipper_length_mm,species) %>%
ggplot(aes(x=year,y=flipper_length_mm,fill=species)) +
geom_col() +
labs(title = "First Plot") +
theme(text = element_text(family = "Georgia")) -> plot1
penguins %>%
select(year, bill_length_mm,species) %>%
ggplot(aes(x=year,y=bill_length_mm,fill=species)) +
geom_col() +
labs(title = "Second Plot") +
theme(text = element_text(family = "Georgia")) -> plot2
cowplot::plot_grid(plot1,plot2)