系统mac os 11
Rstutio Version 1.2.1335
R Version 3.6.2
画图里的中文一直显示成方框。
ggplot()+geom_point(aes(x=ta1$X2011年,y=ta1$X2012))+
xlab("2011年")+ylab("2021年")

解决方案:
使用showtext。
install.packages("showtext", repos = "https://mirrors.ustc.edu.cn/CRAN/")
install.packages("sysfonts", repos = "https://mirrors.ustc.edu.cn/CRAN/")
加载showtext包过程中遇到错误:
‘sysfonts’ Reason: image not found
解决方案:
重新安装XQuartz即可。https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg
library(showtext)
library(ggplot2)
font_files() # 查看字体
#ggplot
ggplot()+geom_point(aes(x=ta1$X2011年,y=ta1$X2012))+
labs(x="2011年",y="2012年",title="ggplot图")+
the
6702



被折叠的 条评论
为什么被折叠?



