ggsave保存图片报错Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
字体类别出错
In addition: There were 50 or more warnings (use warnings() to see the first 50)
解决办法:
#导入windows中的字体库
library(extrafont)
font_import("C:/Windows/Fonts")#选择yes
#看看有哪些字体;
#和Times相关的有下面这些
#C:\Windows\Fonts\times.ttf : TimesNewRomanPSMT already registered in fonts database. Skipping.
#C:\Windows\Fonts\timesbd.ttf : TimesNewRomanPS-BoldMT already registered in fonts database. Skipping.
#C:\Windows\Fonts\timesbi.ttf : TimesNewRomanPS-BoldItalicMT already registered in fonts database. Skipping.
#C:\Windows\Fonts\timesi.ttf : TimesNewRomanPS-ItalicMT already registered in fonts database. Skipping.
#选择一个感兴趣的
library(showtext)
font_add('TNR','C:/Windows/Fonts/times.ttf')
showtext_auto()
#再使用ggsave()就不会报错
参考showtext | R语言绘图字体设置——针对Windows系统_R语言学堂的博客-CSDN博客