This is most likely a font problem. The default font igraph is using to
draw the text labels does not have the characters present. I'm not sure how
to switch the font for raster images (png, etc.), but it is easy to work
around for SVG.

For example,

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import igraph

g = igraph.Graph()

g.add_vertices(3)
g.vs[0]["label"]="母"
g.vs[1]["label"]="私"
g.vs[2]["label"]="ABC"

g.add_edge(0,1)
g.add_edge(1,2)
g.add_edge(2,1)

layout = g.layout("circle")
g.write_svg("tmp.svg", layout = layout)

generates a file called tmp.svg. Opening this in any standard text editor
(e.g. gedit) it is simple to find and replace all instances of the default
font for another font that supports Chinese characters. In my installation
I had to search for "font-family:Sans" and replace "Sans" with another font.

Cheers,
Scott



On Mon, May 5, 2014 at 5:01 PM, <[email protected]> wrote:

>
> ------------------------------
>
> Message: 9
> Date: Mon, 5 May 2014 21:35:19 +0800
> From: =?us-ascii?B?s8K5+sG6?= <[email protected]>
> To: igraph-help <[email protected]>
> Subject: [igraph] Problem with displaying vertex's label text in
>         Chinese characters
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear,
>         I use python-igraph-0.7 on Ubuntu to draw graph.  To display the
> vertex's text, I add its label attribute . As the text are Chinese
> characters of 'unicode' type (not 'str' type),  I encode them by "UTF-8".
> But when the graph is shown, the Chinese characters are show as the small
> squares, unreadable codes. What's wrong with this?thanks very much.
>       Best Wishes!
> -------------- next part --------------
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to