GuyAllard / markov_clustering

markov clustering in python
MIT License
167 stars 37 forks source link

matplotlib window disappearing #4

Open Moonire opened 6 years ago

Moonire commented 6 years ago

I used the exemple scipt and a data set of mine and in both cases the graph plot popped and terminated itself very quickly. I have no issues with matplotlib anywhere else.

Using python 3.6, all modules are up to date since I reinstalled them with markov_clustering

saini5 commented 6 years ago

I'm having the same issue. Python 3.5.2 Networkx 2.1 Matplotlib 2.2.2

GuyAllard commented 6 years ago

Thanks for reporting this issue. I normally use the module from within a Jupyter notebook, and so have not encountered this.

The drawing code assumes an interactive session is being used (e.g. python interactive interpreter / Jupyter notebook). However, when the script is run non-interactively, the matplotlib window closes when the python interpreter exits (which is normal behavior for matplotlib).

I will add an option to the draw_graph function which can be used to specify whether or not the interpreter should wait until the matplotlib window is closed before exiting.

A quick workaround that you can use in the mean time is to add this to the end of your script: input("Press Enter to continue ...")
Now the matplotlib window will stay open until you hit the enter key, causing the program to complete.