Labels in igraph python are plotted wrong

I am having a problem with labels both in edges and vertices in plots. I asked this question in Stack Exchange and they redirected me here. I tried to copy the question but as I am a new user I can not put all the pictures and links. So I would ask you to visit the question for further details.


I have tried to reproduce the problem on my machine, but it works fine for me on macOS. Is this the full code that you posted on SO or has it been stripped down? I have noticed that the figures you posted on SO are smaller than the default igraph plot size, so if this is not the full code that you are using, please post the full code here.

One other thing that I would be interested in: does it also happen if you save the plots to a file? This can be done by adding the filename as the second argument to plot(), after the graph itself; something like:

plot(g, "output.png", ...)


Well, I just did not include the bbox = (300, 300) part.

The full code I use is:

import igraph as ig

g = ig.Graph(directed = True, n=4)
g.add_edges([(0,1), (0,2), (2,3)])["weight"]=[1,2,3]

#1st run["label"] = ["orange", "magenta", "purple"]
g.vs["label"] = ["vA", "vB", "vC", "vD"]

#2nd run["label"] = ["blue", "green", "yellow"]
#g.vs["label"] = ["v1", "v2", "v3", "v4"]

ig.plot(g, "output.png", layout = g.layout("rt"), bbox = (300, 300), edge_width =['weight'])

On the firt run I use the parameters for 1st run, on the 2nd the ones for the 2nd run.

In the first run, both in Visual Studio Code and the output.png the labels are plotted fine. But in the second run, only the output.png is plotted fine. In Visual Studio Coded is displayed:

Thanks! I’m starting to suspect that this has to do something with how VSCode is handling the evaluation of Python code. I’ll try to test and reproduce it with VSCode during the weekend.

1 Like

Ok, thank you a lot!

I have to say too I am running Visual Studio Code interactively using Jupyter code cells.