1. 程式人生 > >R 生成圖片的中文問題

R 生成圖片的中文問題

使用下面的命令生成圖片的 PDF 檔案,則中文無法顯示,同時,如果使用 RCaller 的 java 庫執行時,程式會直接報錯的,大意就是無法識別中文字元。

> pdf('logistic_roc_graph2.pdf')
> plot(ss,main='logistic', xlab='1-specific', ylab='靈敏度')
There were 18 warnings (use warnings() to see them)
> dev.off()

但是,如果改成直接生成 PNG 圖片,則沒有問題,都能通過:

> png('logistic_roc_graph2.png')
> plot(ss,main='logistic', xlab='1-specific', ylab='靈敏度')
> dev.off()
不知道為什麼會是這樣的情況。好在我的專案只需要生成一個檔案供前端下載,無所謂檔案是 PDF 還是 PNG。