Reputation: 147
I have an iGraph object and I want to plot it on a Matplotlib axis,
the code for my graph is
from igraph import Graph, Layout
import igraph as ig
karate = Graph.Famous("Zachary")
layout = karate.layout_kamada_kawai()
visual_style={"bbox": (300, 300), "margin": 15, "layout": layout}
cl = karate.community_fastgreedy()
membership = cl.as_clustering().membership
pal = ig.drawing.colors.ClusterColoringPalette(len(membership))
karate.vs["color"] = pal.get_many(cl.as_clustering().membership)
karate.vs["size"] = 15
the iGraph documentation says that you can plot inside a Matplotlib axis using,
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ig.plot(g, target=ax)
source : https://igraph.org/python/doc/tutorial/visualisation.html
however, when I run,
fig, ax = plt.subplots()
ig.plot(karate, **visual_style, target=ax)
I get the following error,
TypeError: expected str, bytes or os.PathLike object, not AxesSubplot
Can anyone explain what I am doing wrong please? Thanks!
Upvotes: 2
Views: 1148
Reputation: 464
So the pip version of python-igraph is 0.8.3. The documentation you're referring to is the master branch. You can look at the file here and note that matplotlib is not anywhere in the code, but if you look at the master branch here the implementation exists. If you want that functionality, then you can build from source, or wait for the next release.
Upvotes: 2