mnets / pymnet

The original library for analyzing multilayer networks.
https://mnets.github.io/pymnet/
GNU General Public License v3.0
116 stars 24 forks source link

[REVIEW] Figure not showing #28

Open ClaudMor opened 1 week ago

ClaudMor commented 1 week ago

Dear authors,

If I run your tutorial on Visualizing Networks, the figure does not show:

from pymnet import *
net = models.er_multilayer(5,2,0.2)
fig = draw(net,show=True)
C:\Users\claud\anaconda3\envs\pymnet_review\Lib\site-packages\pymnet\visuals\drawbackends\mpl.py:79: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
  plt.show()

I tried installing PyQt6 (as suggested here) to no avail.

Would you have any idea on what could the problem be (perhaps it is related to my machine or environment)?

Environment:

(pymnet_review) C:\Users\claud>conda list
# packages in environment at C:\Users\claud\anaconda3\envs\pymnet_review:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h2bbff1b_6
ca-certificates           2024.3.11            haa95532_0
contourpy                 1.2.1                    pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
expat                     2.6.2                hd77b12b_0
fonttools                 4.53.0                   pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
libffi                    3.4.4                hd77b12b_1
matplotlib                3.9.0                    pypi_0    pypi
networkx                  3.3                      pypi_0    pypi
numpy                     2.0.0                    pypi_0    pypi
openssl                   3.0.14               h827c3e9_0
packaging                 24.1                     pypi_0    pypi
pillow                    10.3.0                   pypi_0    pypi
pip                       24.0            py312haa95532_0
pymnet                    0.2.0                    pypi_0    pypi
pyparsing                 3.1.2                    pypi_0    pypi
pyqt6                     6.7.0                    pypi_0    pypi
pyqt6-qt6                 6.7.2                    pypi_0    pypi
pyqt6-sip                 13.6.0                   pypi_0    pypi
python                    3.12.4               h14ffc60_1
python-dateutil           2.9.0.post0              pypi_0    pypi
scipy                     1.13.1                   pypi_0    pypi
setuptools                69.5.1          py312haa95532_0
six                       1.16.0                   pypi_0    pypi
sqlite                    3.45.3               h2bbff1b_0
tk                        8.6.14               h0416ee5_0
tzdata                    2024a                h04d1e81_0
vc                        14.2                 h2eaa2aa_1
vs2015_runtime            14.29.30133          h43f2093_3
wheel                     0.43.0          py312haa95532_0
xz                        5.4.6                h8cc25b3_1
zlib                      1.2.13               h8cc25b3_1

OS: windows 10

IDE: vscode

cloner174 commented 1 week ago

Hi! The error message typically happens when the default backend does not support interactive plotting. But you have already installed PyQt6, so it seems the backend is not set correctly. To resolve this, I suggest following steps, respectively!

  1. Ensure that the backend is available in your environment:
    import matplotlib
    print(matplotlib.rcsetup.all_backends)
  2. Ensure PyQt6 is Installed Correctly:
    from PyQt6.QtWidgets import QApplication, QLabel
    app = QApplication([])
    label = QLabel("Congratulation!!!!!It's Okkkk")
    label.show()
    app.exec()
  3. Ensure that Matplotlib is set to correct backend:
    
    import matplotlib
    matplotlib.use('QtAgg') #or'Qt5Agg'

from pymnet import * net = models.er_multilayer(5, 2, 0.2) fig = draw(net, show=True)

4. Use Environment Variables:
```bash
export MPLBACKEND=QtAgg  #Unix-based
set MPLBACKEND=QtAgg  #Windows or'Qt5Agg'
  1. Update All Packages:
    conda update --all
  2. Test in a Different Environment:
    conda create -n test_ python=3.12 matplotlib pyqt6 pymnet
    conda activate test_
ClaudMor commented 4 days ago

Hi @cloner174 , I tried all your steps, but still it doesn't work. More details below.

  1. print(matplotlib.rcsetup.all_backends)

    yields

    <stdin>:1: MatplotlibDeprecationWarning: The all_backends attribute was deprecated in Matplotlib 3.9 and will be removed 
    in 3.11. Use ``matplotlib.backends.backend_registry.list_builtin()`` instead.
    ['gtk3agg', 'gtk3cairo', 'gtk4agg', 'gtk4cairo', 'macosx', 'nbagg', 'notebook', 'qtagg', 'qtcairo', 'qt5agg', 'qt5cairo', 'tkagg', 'tkcairo', 'webagg', 'wx', 'wxagg', 'wxcairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']
  2. import matplotlib
    matplotlib.use('QtAgg') #or'Qt5Agg'

Gives no output (so maybe it works).

  1. and 5. After entering
    set MPLBACKEND=QtAgg

and retrying to draw with show=True it still doesn't show. Same for conda update --all.

The env is:

(pymnet_review_1) E:\GitHub\pymnet_review\Claudio\pymnet-master>conda list
# packages in environment at C:\Users\claud\anaconda3\envs\pymnet_review:
#
# Name                    Version                   Build  Channel
bliss-bind                0.2.0                    pypi_0    pypi
bzip2                     1.0.8                h2bbff1b_6
ca-certificates           2024.3.11            haa95532_0
contourpy                 1.2.1                    pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
expat                     2.6.2                hd77b12b_0
fonttools                 4.53.1                   pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
libffi                    3.4.4                hd77b12b_1
matplotlib                3.9.1                    pypi_0    pypi
networkx                  3.3                      pypi_0    pypi
numpy                     2.0.0                    pypi_0    pypi
openssl                   3.0.14               h827c3e9_0
packaging                 24.1                     pypi_0    pypi
pillow                    10.4.0                   pypi_0    pypi
pip                       24.0            py312haa95532_0
pymnet                    0.2.0                    pypi_0    pypi
pyparsing                 3.1.2                    pypi_0    pypi
pyqt6                     6.7.0                    pypi_0    pypi
pyqt6-qt6                 6.7.2                    pypi_0    pypi
pyqt6-sip                 13.6.0                   pypi_0    pypi
python                    3.12.4               h14ffc60_1
python-dateutil           2.9.0.post0              pypi_0    pypi
scipy                     1.14.0                   pypi_0    pypi
setuptools                69.5.1          py312haa95532_0
six                       1.16.0                   pypi_0    pypi
sqlite                    3.45.3               h2bbff1b_0
tk                        8.6.14               h0416ee5_0
tzdata                    2024a                h04d1e81_0
vc                        14.2                 h2eaa2aa_4
vs2015_runtime            14.29.30133          h43f2093_4
wheel                     0.43.0          py312haa95532_0
xz                        5.4.6                h8cc25b3_1
zlib                      1.2.13               h8cc25b3_1

and

(pymnet_review_1) E:\GitHub\pymnet_review\Claudio\pymnet-master>pip list
Package         Version     Editable project location
--------------- ----------- ---------------------------------------------
bliss-bind      0.2.0
contourpy       1.2.1
cycler          0.12.1
fonttools       4.53.1
kiwisolver      1.4.5
matplotlib      3.9.1
networkx        3.3
numpy           2.0.0
packaging       24.1
pillow          10.4.0
pip             24.0
pymnet          0.2.0       E:\GitHub\pymnet_review\Claudio\pymnet-master
pyparsing       3.1.2
PyQt6           6.7.0
PyQt6-Qt6       6.7.2
PyQt6-sip       13.6.0
python-dateutil 2.9.0.post0
scipy           1.14.0
setuptools      69.5.1
six             1.16.0
wheel           0.43.0