我的操作系统上安装了字体,所以这段代码运行良好:
library(tidyverse)
library(extrafont)
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "Metropolis")
)
让我们强制一个错误(注意我写的是“metropolis”,而不是“Metropolis”):
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "metropolis")
)
这给了我一个错误,这没关系,因为字体“metropolis”不存在。
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
有没有一种方法可以让我在 R 中验证是否安装了某些字体?先感谢您。