2012-10-18 10 views
1

我的問題與我以前的問題有關。如何在pdf上繪製中文字符?

How to plot bar plot with Chinese names in input file?

我需要繪製的PDF現在中國文字。

mydata = matrix(c(2:6, c(2,4,2,6,3)), nrow= 2) 
mylabs = c("木材", "表", "筆", "垃圾桶", "杯") 
barplot(mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c("red", "blue")) 

pdf("plotname.pdf") 
barplot(mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c("red", "blue")) 
dev.off() 

但只有pdf才能打印出來,而不是中文名稱。

問候

回答

2

試試這個:

cairo_pdf("plotname.pdf") 
barplot(mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c("red", "blue")) 
dev.off() 
+0

好了,但是我在我的Linux得到以下錯誤消息當我使用開羅命令加載失敗開羅DLL – Manish

+0

親愛的Manish,你的Ubuntu有點**錯誤。我也使用10.04,默認界面,它就像一個魅力。 – January

0

我有同樣的問題,因爲你(我在Mac上有R 2.14.2和區域設置法語)。
我設法在pdf調用指定的字體系列「GB1」(簡體中國)得到解決:

pdf("plotname.pdf" , family="GB1") 
barplot(mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c("red", "blue")) 
dev.off() 
+0

這是非常有用的,但爲了看到中文字符,我需要爲adobe reader安裝中文字體。 – Manish