ggplot 中对theme 定义的文字类型,是限定在geom_text
以外的,是几何对象aes 以外的文字部分,因此是theme 是无法对其统一修改的。
比如:
d <- data.frame(x=rnorm(10), y=rnorm(10), lab=LETTERS[1:10])
p <- ggplot(d, aes(x, y)) +
geom_text(aes(label=lab, color=lab), size=10) +
geom_text(aes(y, x, label=lab), size=3)
p + theme(text = element_text(family = "gochi"))
直接在原本的图像对象基础之上使用:
library(yyplot)
g <- set_font(p, family="gochi", color="firebrick", size=5)
grid::grid.draw(g) # 最后需要手动输出一下
ps:y 叔叔的这个包有点粗暴,全部文字都变啦~
当然这个包,我还是以好玩为主~
[1]设置ggplot所有字体 (guangchuangyu.github.io): https://guangchuangyu.github.io/cn/2017/09/ggplot2-set-font/