python-igraph
                                
                                 python-igraph copied to clipboard
                                
                                    python-igraph copied to clipboard
                            
                            
                            
                        Error: igraph.drawing.cairo.plot.cairo.MemoryError: out of memory
Copy from https://github.com/igraph/igraph/issues/2230
Describe the bug
Traceback (most recent call last):
  File "C:\Users\Max\Desktop\graphs-generation\graphs.py", line 40, in <module>
    igraph.plot(g, target='myfile.pdf')
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\igraph\drawing\__init__.py", line 284, in plot
    result.save()
  File "C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\igraph\drawing\cairo\plot.py", line 317, in save
    self._ctx.show_page()
igraph.drawing.cairo.plot.cairo.MemoryError: out of memory
To reproduce
import igraph
import matplotlib.pyplot as plt
print(igraph.__version__)
m1 = [
    [1, 2, 3, 4, 5, 7, 6],
    [1, 2, 3, 5, 4, 6, 7],
    [1, 2, 4, 3, 5, 6, 7],
    [1, 2, 5, 4, 3, 6, 7],
    [2, 1, 3, 4, 5, 6, 7],
    [6, 7, 3, 4, 5, 1, 2],
    [7, 6, 3, 4, 5, 2, 1],
]
g = igraph.Graph.Adjacency(m1)
print(g)
print(g.get_adjacency())
igraph.plot(g, target='myfile.pdf')
Version information 0.10.1
My problem was solved by converting the graph to networkx and using networkx to draw, but I think it's good to keep this issue to report this bug when we want to use igraph to draw and don't want to use networkx.
import igraph as ig
import networkx as nx
import matplotlib.pyplot as plt
m = [
    [1, 2, 3, 4, 5, 7, 6],
    [1, 2, 3, 5, 4, 6, 7],
    [1, 2, 4, 3, 5, 6, 7],
    [1, 2, 5, 4, 3, 6, 7],
    [2, 1, 3, 4, 5, 6, 7],
    [6, 7, 3, 4, 5, 1, 2],
    [7, 6, 3, 4, 5, 2, 1],
]
g = ig.Graph.Adjacency(m)
n = g.to_networkx()
nx.draw(n)
plt.savefig("path.png")
Then you for reporting. I'll take a look ASAP, it looks mighty weird.
Do you know what Cairo backend library are you using?
Then you for reporting. I'll take a look ASAP, it looks mighty weird.
Do you know what Cairo backend library are you using?
Thank you. About the Cairo library, Yes I installed it today by using pip install.
Let me know if you need any more information or details. I can test if needed. @iosonofabio
Yes... which Cairo library did you install using pip? The are two out there that we support
Thank you
On Thu, Oct 6, 2022, at 12:20, Max Base wrote:
Then you for reporting. I'll take a look ASAP, it looks mighty weird.
Do you know what Cairo backend library are you using?
Thank you. About the Cairo library, Yes I installed it today by using
pip install.— Reply to this email directly, view it on GitHub https://github.com/igraph/python-igraph/issues/588#issuecomment-1269181573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJFEAC4KJWW5G5MOAPOIETWBYSOJANCNFSM6AAAAAAQ6BU7PU. You are receiving this because you commented.Message ID: @.***>
Q: Can you tell me the names of both libraries that igraph supported?
I just runned:
pip3 install pycairo
Requirement already satisfied: pycairo in c:\users\max\appdata\local\programs\python\python310\lib\site-packages (1.21.0)
Thank you, that's fine. I'll try to reproduce this afternoon and get back to you
I installed igraph==0.10.1 and pycairo==1.21.0 in a virtual environment on my machine and cannot reproduce the error. In fact, I get the plot below:
which looks just fine.
I'm on Linux and you're likely on some Windows version, however the plotting code itself does not rely on any OS-specific tricks explicitely (upstream libraries e.g. pycairo might, of course).
Can you try to:
- reboot your machine
- create a whole new python environment (or wipe and recreate this one)
- install only pycairo and igraph in their exact versions in the new environment
- run the code you specified above
and see if it still fails?
Also, notice that you don't need to import pyplot since you're using cairo, not matplotlib as a backend.
I cannot reproduce this issue either on my machine (with Cairo 1.21.0), but it's definitely weird. Trying to reproduce the problem in a clean virtualenv on Windows would definitely help.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
Closing as cannot reproduce, if this is still open please reopen the issue.