[英]How to plot chinese characters on pdf?
My question is related to my previous question. 我的问题与我之前的问题有关。
How to plot bar plot with Chinese names in input file? 如何在输入文件中绘制带有中文名称的条形图?
I need to plot now chinese characters on pdf. 我需要在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()
But on pdf only .... gets printed instead of Chinese names. 但仅在pdf ....打印而不是中文名称。
Regards 问候
Try this: 尝试这个:
cairo_pdf( "plotname.pdf" )
barplot( mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c( "red", "blue" ) )
dev.off()
I had the same problem as yours (I'm on a Mac with R 2.14.2 and locale settings in french). 我遇到了和你一样的问题(我在Mac上使用R 2.14.2和法语区域设置)。
I managed to get around by specifying the font family "GB1" (Simplified Chinese) in the pdf
call: 我设法通过在pdf
调用中指定字体系列“GB1”(简体中文)来解决:
pdf( "plotname.pdf" , family="GB1")
barplot( mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c( "red", "blue" ) )
dev.off()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.