1.查看当前的ggplot2默认字体
theme_get()$text
显示一个list,family为默认空白,默认是sans(Arial字体)。
List of 11
$ family : chr “”
$ face : chr “plain”
$ colour : chr “black”
$ size : num 11
$ hjust : num 0.5
$ vjust : num 0.5
$ angle : num 0
$ lineheight : num 0.9
$ margin : ‘margin’ num [1:4] 0pt 0pt 0pt 0pt
…- attr(, “valid.unit”)= int 8
…- attr(, “unit”)= chr “pt”
$ debug : logi FALSE
$ inherit.blank: logi TRUE
- attr(*, “class”)= chr [1:2] “element_text” “element”
2.查看Windows系统下的字体
windowsFonts()
显示如下,
$serif
[1] “TT Times New Roman”
$sans
[1] “TT Arial”
$mono
[1] “TT Courier New”
3.修改成Time New Roman
修改theme函数,family指定serif(Times New Roman)即可。
p+theme(text=element_text(size=16, family="serif"))
对于导入其它字体,参考extrafont包。
4.参考文献
【1】https://stackoverflow.com/questions/34610165/what-is-the-default-font-for-ggplot2
【2】https://stackoverflow.com/questions/34522732/changing-fonts-in-ggplot2