# Labels in igraph python are plotted wrong

**URL:** <https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513>\
**Category:** Usage\
**Tags:** Python\
**Created:** [13 November 2020 16:21 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513 "2020-11-13T16:21:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Puco4](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Puco4](https://igraph.discourse.group/u/Puco4)\
**Post date:** [13 November 2020 16:21 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513/1 "2020-11-13T16:21:18Z")

</div>

I am having a problem with labels both in edges and vertices in plots. I asked this question in [Stack Exchange](https://stackoverflow.com/questions/64823156/labels-in-igraph-python-are-plotted-wrong) 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.

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [13 November 2020 17:14 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513/2 "2020-11-13T17:14:39Z")

</div>

Hello!

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", ...)`

---

<div class="post-metadata">

**Author:** ![Puco4](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Puco4](https://igraph.discourse.group/u/Puco4)\
**Post date:** [13 November 2020 18:29 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513/3 "2020-11-13T18:29:55Z")

</div>

Hi!

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

The full code I use is:

```python
import igraph as ig

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

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

#2nd run
#g.es["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 = g.es['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:

 ![p2](https://global.discourse-cdn.com/free1/uploads/igraph/original/1X/d777a4cdb163187d1d21190b4360aed51d016f28.png)

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [13 November 2020 20:08 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513/4 "2020-11-13T20:08:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Puco4](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Puco4](https://igraph.discourse.group/u/Puco4)\
**Post date:** [13 November 2020 20:38 UTC](https://igraph.discourse.group/t/labels-in-igraph-python-are-plotted-wrong/513/5 "2020-11-13T20:38:25Z")

</div>

Ok, thank you a lot!

I have to say too I am running Visual Studio Code interactively using [Jupyter code cells](https://code.visualstudio.com/docs/python/jupyter-support-py).
