[BioC] Chinese label in Rgraphviz

Michael michaellibeijing at gmail.com
Sat Oct 10 07:12:13 CEST 2009


Dear List members,
I wonder any person tried displaying Chinese labels with Rgraphviz.
Typically, one saves the dot file with Chinese labels in UTF-8, and
issue command "dot -Nfontname=simsun filename.dots  -Tpng -o
filename.png" in dos windows.  The png picture would display the
Chinese characters correctly.

But the same trick seems failed in Rgraphviz.
>library(Rgraphviz)
>set.seed(123)
>V <- paste(letters[1:5],"test中文",sep="")
>M <- 1:4
>g1 <- randomGraph(V, M, 0.2)
>graph.par(list(graph=list(charset="latin1"),
				nodes=list(col="red", fontname="simsun")))
>g <- layoutGraph(g1)
"Error: Invalid 2-byte UTF8 found in input. Perhaps "-Gcharset=latin1"
is needed?"
And the R session collapsed again.

WIth the following codes, there is no error, but the label displayed
with stranged characters instead of  Chinese charaters.
>library(Rgraphviz)
>set.seed(123)
>V <- paste(letters[1:5],"test中文",sep="")
>M <- 1:2
>g1 <- randomGraph(V, M, 0.2)
>plot(g1, attrs=list(graph=list(charset="latin1"),
				node=list(fontname="simsun")))

I wonder whether it is possible for Rgraphviz to display Chinese
characters correctly.
Any suggestion would be appreciated.

Regards,
Michael



> sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese (Simplified)_People's Republic of
China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

other attached packages:
[1] Rgraphviz_1.22.1 graph_1.22.5

loaded via a namespace (and not attached):
[1] tools_2.9.2



More information about the Bioconductor mailing list