You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I execute a netgraph example as a Python script, the plot window appears and disappears almost instantly. However, when I execute each line of code in the Python prompt, the plot window stays.
What you describe is expected behavior for any python script: once the script terminates, the python process (and any child process thereof) is killed.
So what is happening in your MWE:
You run the script, i.e. a python process is created which evaluates your script line-by-line, and the figure is created. Figure creation spawns a child process that displays the rendered image.
As you are in interactive mode (plt.ion()), figure creation is non-blocking, i.e. the rest of the script is evaluated until you reach the end of file.
At this point, the python parent process is terminated. The OS realizes that the figure is in an orphan child process and kills it as well.
Solution: don't use interactive mode, and force the figure display with plt.show() after netgraph.draw() or equivalent.
When I execute a netgraph example as a Python script, the plot window appears and disappears almost instantly. However, when I execute each line of code in the Python prompt, the plot window stays.
An MWE:
The same problem occurs with networkx directed graphs as well.
The text was updated successfully, but these errors were encountered: