0

The vertex labels when I plot the graph in ipython notebook inline are all messed up. This problem does not exist when I look at graph.pdf (see code below). I do not have enough stackoverflow reputation to post images here, but I have the pdf file and I can send it over if anyone is interested.

Here is the code snipet:

layout = g.layout("random")
visual_style = {}
visual_style["vertex_label"] = g.vs["label"]
visual_style["vertex_label_size"] = 2
visual_style["vertex_color"] = [color_dict[vert] for vert in g.vs["label"]]
visual_style["bbox"] = (500,500)
visual_style["margin"] = 20
visual_style["layout"] = layout    

plot(g, 'graph.pdf', **visual_style)

In short, g contains my graph, and is created using a list of vertices and a list of edges.

g = Graph(vertex_attrs={"label": vertices}, edges=edges, directed=False)

The vertices of g have labels. These labels are things like, 'WRL-Africa' , 'SOC-crime' , 'SPO-soccer' and etc.

Each label is associated with a color through color_dict as follows,

color_dict = {'WRL-Africa':'#A52A2A', 'SOC-crime':'#006400', 'SPO-soccer':'#B22222'}

Why is this happening? It seems to be a bounding box issue. Thanks in advance for any help.

JRun
  • 669
  • 1
  • 10
  • 17
  • Seems to be a duplicate of http://stackoverflow.com/questions/30640489/issue-plotting-vertex-labels-using-igraph-in-ipython – Tamás Jun 04 '15 at 14:12
  • Not really. The problem in the link above is that there are no labels at all. I have a different issue: when I look at my saved files (pdf, png or whatever format), labels are there and are quite fine. It is just in my ipython notebook that they are messed up--all letters crammed up in a small bounding box I think. I will take your advice in the posted link and wont change the `igraph/drawing/__init__.py` file. – JRun Jun 05 '15 at 19:45
  • This looks similar to me; the problem in that other post happens only in the IPython notebook as well. Basically, there's something wrong in the SVG implementation of Qt (on which the IPython notebook is based), or igraph is using SVG incorrectly (not sure which is the case) and QtSVG is not able to render the fonts. Saving a figure to PDF or PNG or whatever format skips Qt entirely, so there's no problem there. – Tamás Jun 05 '15 at 19:51

0 Answers0