本文轉載自:https://blog.csdn.net/hongweigg/article/details/47907555 函數
在使用pdf()函數時,要輸出中文,只有一種字體可選。例子:字體
pdf("chinese.pdf",family="GB1")
plot(m2,xlab="高度",ylab="體重",main="統計")
dev.off().net
這裏字體參數family只能設置成"GB1"(不知是否還有其餘字體可選),默認宋體。blog
在使用Cairo包時,進行中文輸出時,能夠選擇多種字體。不過這個包要先下載安裝。it
例子:pdf
(未檢驗)基礎
CairoPDF("chinese.pdf",family="SimSun")下載
plot(1:10,1:10,type="n");
text(2,10,"宋體",family="SimSun");
text(2,8,"黑體",family="SimHei");
text(2,6,"楷體",family="KaiTi_GB2312");
text(2,4,"隸書",family="LiSu");
text(2,2,"幼圓",family="YouYuan");
text(6,10,"Arial",family="Arial");
text(6,8,"Times New Roman",family="Times New Roman");
text(6,6,"Courier New",family="Courier New");
text(6,4,"Consolas",family="Consolas");
text(6,2,"Symbol",family="Symbol");
dev.off();im
family參數爲字體名稱,如宋體:SimSun,黑體:SimHei。統計
新細明體, PMingLiU , 細明體, MingLiU, 標楷體, DFKai-SB, 黑體, SimHei, 宋體, SimSun , 新宋體, NSimSun, 仿宋, FangSong, 楷體, KaiTi, 仿宋_GB2312, FangSong_GB2312, 楷體_GB2312, KaiTi_GB2312, 微軟正黑體, Microsoft JhengHei, 微軟雅黑, Microsoft YaHei, 隸書, LiSu, 幼圓, YouYuan, 華文細黑, STXihei, 華文楷體, STKaiti, 華文宋體, STSong, 華文中宋, STZhongsong, 華文仿宋, STFangsong, 方正舒體 , FZShuTi, 方正姚體, FZYaoti, 華文彩雲, STCaiyun, 華文琥珀, STHupo, 華文隸書, STLiti, 華文行楷, STXingkai, 華文新魏, STXinwei