Hi,
When using python-igraph's matplotlib backend, I have experienced some interoperability issues with the mark_groups functionality of the plot command. When I create a VertexClustering object (see working example) and try to visualize its groups without additional markup, everything works fine and I get a clean output as shown in the figure below.
# WORKING EXAMPLE
import igraph as ig
import matplotlib.pyplot as plt
import random
random.seed(42)
visual_style = {}
g = ig.Graph.Erdos_Renyi(20,0.2)
communities = g.community_multilevel()
graph_layout = g.layout("kk")
visual_style["vertex_size"] = 10
# visual_style["vertex_color"] = "red"
visual_style["layout"] = graph_layout
fig, ax = plt.subplots()
ig.plot(communities,
mark_groups=True,
target=ax,
**visual_style)

However, when I try to add vertex color to the visual_style dictionary (i.e. uncomment line 16) , I get the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-77-bab2d710ea9e> in <module>
19 fig, ax = plt.subplots()
20
---> 21 ig.plot(communities,
22 mark_groups=True,
23 target=ax,
~/miniconda3/envs/immuno/lib/python3.9/site-packages/igraph/drawing/__init__.py in plot(obj, target, bbox, *args, **kwds)
480 if hasattr(plt, "Axes") and isinstance(target, plt.Axes):
481 result = MatplotlibGraphDrawer(ax=target)
--> 482 result.draw(obj, *args, **kwds)
483 return
484
~/miniconda3/envs/immuno/lib/python3.9/site-packages/igraph/drawing/graph.py in draw(self, graph, *args, **kwds)
1079 # Mark groups
1080 if "mark_groups" in kwds:
-> 1081 for idx, color in kwds["mark_groups"].items():
1082 points = [vcoord[i] for i in idx]
1083 vertices = np.asarray(convex_hull(points, coords=True))
AttributeError: 'bool' object has no attribute 'items'
When using the regular plotting route, you can change the vertex color while marking the communities with the shaded area. Is this also possible with the matplotlib backend in any sort of way?
Version information
# Name Version Build Channel
python-igraph 0.9.1 py39hfef886c_0 conda-forge
Hi,
When using python-igraph's matplotlib backend, I have experienced some interoperability issues with the
mark_groupsfunctionality of theplotcommand. When I create aVertexClusteringobject (see working example) and try to visualize its groups without additional markup, everything works fine and I get a clean output as shown in the figure below.However, when I try to add vertex color to the
visual_styledictionary (i.e. uncomment line 16) , I get the following error:When using the regular plotting route, you can change the vertex color while marking the communities with the shaded area. Is this also possible with the matplotlib backend in any sort of way?
Version information