1

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.

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.

Regards

2 Answers 2

3

Try this:

cairo_pdf( "plotname.pdf" )
barplot( mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c( "red", "blue" ) )
dev.off()
Sign up to request clarification or add additional context in comments.

2 Comments

Ok, But i m getting following error message on my linux when i use cairo command failed to load cairo DLL
Dear Manish, something is wrong with your Ubuntu. I also use 10.04, default interface, and it works like a charm.
2

I had the same problem as yours (I'm on a Mac with R 2.14.2 and locale settings in french).
I managed to get around by specifying the font family "GB1" (Simplified Chinese) in the pdf call:

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

1 Comment

This is very useful but in order to see the chinese characters, i need to install chinese font for adobe reader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.