[R-SIG-Mac] Plotting Chinese characters

Simon Urbanek simon.urbanek at r-project.org
Wed Feb 9 23:03:52 CET 2011


Alberto,

you simply need a font that has those characters. For example on 10.6 this works:

plot.new(); plot.window(0:1,0:1); text(0.5,0.5,"精市",cex=10,family="Hei")

You may want to check your system for fonts that you can use (those that have chinese characters when you click on them in Font Book). There are a lot of fonts that work like STSong, STFangsong, LiSong Pro, AppleMyungjo, GungSeo etc.

Cheers,
Simon


On Feb 9, 2011, at 3:59 PM, Alberto Pepe wrote:

> (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
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list