拓端tecdat|R语言作图不显示中文解决办法,如何使用中文字体

原文链接:http://tecdat.cn/?p=14987 


预期

R语言绘图中的中文默认字体宋体,希望用其他字体绘图,保存成PDF格式不能识别中文。

实际

使用“雅黑字体”出现乱码

 

重现问题的步骤

Windows7系统,R ×64 3.2.0
 

 

  1.  
    windowsFonts(
  2.  
    + A=windowsFont("华文彩云"),
  3.  
    + B=windowsFont("华文仿宋"),
  4.  
    + C=windowsFont("华文行楷"),
  5.  
    + D=windowsFont("华文楷体"),
  6.  
    + E=windowsFont("华文隶书"),
  7.  
    + F=windowsFont("华文中宋"),
  8.  
    + G=windowsFont("华文细黑"),
  9.  
    + H=windowsFont("微软雅黑"),
  10.  
    + J=windowsFont("华文新魏"),
  11.  
    + K=windowsFont("幼圆")
  12.  
    + )
  13.  
    plot(1:10,1:10,type="n")
  14.  
    text(2,10,"华文彩云",family="A");
  15.  
    text(2,8,"华文仿宋",family="B");
  16.  
    text(2,6,"华文行楷",family="C");
  17.  
    text(2,4,"华文楷体",family="D");
  18.  
    text(2,2,"幼圆",family="K");
  19.  
    text(6,10,"华文隶书",family="E")
  20.  
    text(6,8,"华文中宋",family="F")
  21.  
    text(6,6,"华文细黑",family="G")
  22.  
    text(6,4,"微软雅黑",family="H")
  23.  
    text(6,2,"华文新魏",family="J")


R中字样例.png

▍关注我们 【大数据部落】第三方数据服务提供商,提供全面的统计分析与数据挖掘咨询服务,为客户定制个性化的数据解决方案与行业报告等。 ▍咨询链接:http://y0.cn/teradat ▍联系邮箱:3025393450@qq.com
原文地址:https://www.cnblogs.com/tecdat/p/13604847.html