vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
596 stars 78 forks source link

`ig.plot(partition)` doesn't work #69

Closed RongqinChen closed 3 years ago

RongqinChen commented 3 years ago

Dear Vincent, Thanks for the excellent work!

I'm getting a AttributeError when I try to plot the partitioning result.

Version of my igraph and leidenalg are 0.9.0 and 0.8.4 separately. Code for testing is copied from the document, which is

import leidenalg as la
import igraph as ig

G = ig.Graph.Famous('Zachary')

partition = la.find_partition(G, la.ModularityVertexPartition)

print(partition)

ig.plot(partition) 

The error that arise is

    ig.plot(partition) 
  File "my_env/lib/python3.7/site-packages/igraph/drawing/__init__.py", line 488, in plot
    result = Plot(target, bbox, background=kwds.get("background", "white"))
  File "my_env/lib/python3.7/site-packages/igraph/drawing/__init__.py", line 126, in __init__
    self._surface_was_created = not isinstance(target, cairo.Surface)
  File "my_env/lib/python3.7/site-packages/igraph/drawing/utils.py", line 410, in __getattr__
    raise AttributeError("plotting not available")
AttributeError: plotting not available

Thank you for your time.

vtraag commented 3 years ago

Good to see you managed to solve the issue @RongqinChen! If any others pass by here, the problem is that cairo was not installed. You can install either pycairo or cairocffi, both should work in principle.

RongqinChen commented 3 years ago

Yes, I solved the problem by installing the packages you mentioned. Thank you for your reply.