# Error in igraph plotting - plot parameter

**URL:** <https://igraph.discourse.group/t/error-in-igraph-plotting-plot-parameter/628>\
**Category:** Usage\
**Tags:** Python\
**Created:** [16 February 2021 14:49 UTC](https://igraph.discourse.group/t/error-in-igraph-plotting-plot-parameter/628 "2021-02-16T14:49:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasmiguel](https://avatars.discourse-cdn.com/v4/letter/l/67e7ee/32.png) [@lucasmiguel](https://igraph.discourse.group/u/lucasmiguel)\
**Post date:** [16 February 2021 14:49 UTC](https://igraph.discourse.group/t/error-in-igraph-plotting-plot-parameter/628/1 "2021-02-16T14:49:41Z")

</div>

Hello everyone,

I’m trying to plot a graph with python-igraph, but it insists on a parameter passing error in the plot function. The arguments in question are those of visualization style. Can anybody help me?

Thanks!

_Line of code:_  
visual\_style = {}  
visual\_style[“vertex\_size”] = d  
visual\_style[“vertex\_color”] = df[‘color’]  
visual\_style[“vertex\_label”] = df[‘genes’]  
visual\_style[“edge\_width”] = report[‘edge\_weight’]  
visual\_style[“edge\_color”] = report[‘color’]  
**ig.plot (g, “graph.pdf”, \*\* visual\_style)**

Error:  
File “test-plotting.py”, line 128, in   
ig.plot (g, “graph.pdf”, \*\* visual\_style)  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/ **init**.py”, line 486, in plot  
result.save ()  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/ **init**.py”, line 288, in save  
self.redraw ()  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/ **init**.py”, line 272, in redraw  
plotter (ctx, bbox, palette, \* args, \*\* kwds)  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/ **init**.py”, line 3734, in **plot**  
drawer.draw (self, palette, \* args, \*\* kwds)  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/graph.py”, line 260, in draw  
edge\_builder = edge\_drawer.VisualEdgeBuilder (graph.es, kwds)  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/metamagic.py”, line 220, in **init**  
values ​​= self._collect\_attributes (attr\_spec)  
File “/home/lucasmiguel/.local/lib/python3.5/site-packages/igraph/drawing/metamagic.py”, line 286, in collect\_attributes  
if not result:  
File “/usr/local/lib/python3.5/dist-packages/pandas/core/generic.py”, line 1573, in **nonzero**  
.format (self ._ class **.** name\_\_))  
**ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool (), a.item (), a.any () or a.all ().**

---

<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:** [16 February 2021 16:47 UTC](https://igraph.discourse.group/t/error-in-igraph-plotting-plot-parameter/628/2 "2021-02-16T16:47:40Z")

</div>

The problem is most likely that `df["color"]` and/or `df["genes"]` is a Pandas data frame. (It could be any other attribute of `visual_style` as well). igraph tries to convert one of these into a Boolean in `igraph/drawing/metamagic.py`, but Pandas data series and NumPy arrays cannot simply be cast to a boolean. The easiest workaround is to ensure that all the values in `visual_style` are lists and to convert them to lists if they aren’t.

---

<div class="post-metadata">

**Author:** ![gattingmk](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@gattingmk](https://igraph.discourse.group/u/gattingmk)\
**Post date:** [29 March 2022 06:39 UTC](https://igraph.discourse.group/t/error-in-igraph-plotting-plot-parameter/628/3 "2022-03-29T06:39:00Z")

</div>

> [@lucasmiguel](#):
>
> ValueError: The truth value of a Series is ambiguous.

[Python](http://net-informations.com/python/default.htm) Pandas follows the numpy convention of raising an error when you try to convert something to a bool. This happens in a if or when using the boolean operations, and, or, or not. It is not clear what the result of.

example

`5 == pd.Series([12,2,5,10])`

The result you get is a Series of booleans, equal in size to the pd.Series in the right hand side of the expression. So, you get an error. The problem here is that you are comparing a pd.Series with a value, so you’ll have multiple True and multiple False values, as in the case above. This of course is ambiguous, since the condition is neither True or False. You need to further aggregate the result so that a single boolean value results from the operation. For that you’ll have to use either any or all depending on whether you want at least one (any) or all values to satisfy the condition.

```auto
(5 == pd.Series([12,2,5,10])).all()
# False

```

or

```auto
(5 == pd.Series([12,2,5,10])).any()
# True

```
