其他分享
首页 > 其他分享> > R语言中作图字体的设置

R语言中作图字体的设置

作者:互联网

介绍

在R语言中设置字体时需要利用**windowsFonts()**加入到字体库中,例如:

windowsFonts(myFont = windowsFont("微软雅黑"))

然后在调用时,用family='myFont’的参数实现即可。

改变ggplot()中的字体

my_theme <- theme(
  panel.background = element_rect(fill = "transparent", colour = NA), 
  plot.background = element_rect(fill = "transparent", colour = NA),
  legend.background = element_rect(fill = "transparent", colour = NA),
  panel.grid.minor = element_blank(), 
  panel.grid.major = element_blank(),
  title=element_text(family="myFont"),
  legend.text=element_text(size=14,family = 'myFont'),
    axis.title=element_text(size=14,family = 'myFont'),
      axis.text = element_text(size=14,family = 'myFont'),
 strip.text.x=element_text(size=14, family='myFont')
)

改变plot()中的字体

plot(1:10,1:10,xlab='好好学习',ylab='你好',cex.lab=2,family='myFont')

标签:plot,family,10,作图,myFont,字体,设置,windowsFonts
来源: https://blog.csdn.net/qq_18055167/article/details/123646961