http://stackoverflow.com/questions/4094094/modifying-fonts-in-ggplot2
使用windowsFonts這個函數(shù)就可以達到要求,如下是我自己為了畫線性回歸而寫的一個theme:
library(ggplot2)
windowsFonts(HEL=windowsFont("Helvetica CE 55 Roman"),
RMN=windowsFont("Times New Roman"),
ARL=windowsFont("Arial"))
old_theme <- theme_update(
plot.title=theme_text(family="ARL", size=18, face="bold", colour="black"),
axis.title.x=theme_text(family="HEL", size=15, colour="black"),
axis.title.y=theme_text(family="HEL", size=15, angle=90, colour="black"),
axis.text.x=theme_text(family="RMN", size=11, colour="black"),
axis.text.y=theme_text(family="RMN", size=11, colour="black"),
axis.ticks=theme_segment(colour="black"),
panel.grid.major=theme_blank(),
panel.grid.minor=theme_blank(),
panel.background=theme_blank(),
axis.line=theme_segment(size=1)
)
運行如上的程序,直接調(diào)用函數(shù)畫圖:
運行的效果:
我把gglot2里面的背景、框線都給去掉了,當然,上圖還需要進一步的修飾,不過離要求已經(jīng)很近了。折騰了半天的經(jīng)驗跟大家分享一下。