[R-SIG-Mac] Plotting Chinese characters

Alberto Pepe apepe at cfa.harvard.edu
Wed Feb 9 21:59:24 CET 2011


(reposting here, from r-help, as requested)

Hi,

I have read some of the documentation relative to character encodings
and non-standard fonts (including previous answered questions and the
2006-2 R issue), but I am still struggling with very basic plotting of
Chinese text.

I have a network, g, of Chinese characters (each node is a Chinese
character) and I can handle it and display it fine within R using
package igraph. However, when I try to plot this network, node names
do not display in the plot. I am trying to produce a visualization of
the character network, like this:

> plot(g, layout=layout.fruchterman.reingold, vertex.color="black", vertex.size=2.0, edge.color="gray70", vertex.label=V(g)$name, edge.arrow.size=0.3)

where g is a an igraph network:

> g
Vertices: 199
Edges: 123
Directed: TRUE
Edges:

[0]   '精' -> '神'
[1]   '市' -> '场'
[2]   '思' -> '想'
...

The names of the nodes (labels) do not display in the plot. I have
noted that this is not a problem linked to igraph or network
visualization. Even if I try to plot an empty chart with a title that
contains one of the chinese characters above, these characters do not
display.

What is the simplest way to display these non-standard fonts in a R plot?

I am using R for Mac OS X GUI 1.35-dev Leopard build 32-bit:
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      tools     stats     graphics  grDevices utils
datasets  methods   base

other attached packages:
[1] igraph_0.5.5-1

Thanks,
Alberto Pepe



More information about the R-SIG-Mac mailing list