拓端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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM