Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continue executing a python script while showing a plot/figure? [duplicate]

Possible Duplicate:
Is there a way to detach matplotlib plots so that the computation can continue?

I use python with matplotlib for scientific programming. But whenever I use the command show() to display a plot, the script just stops there. I have to close the figure window for the script to continue executing. Is there a way to keep the script running while the figure window is open, just like in Matlab?

like image 819
LWZ Avatar asked Aug 10 '12 17:08

LWZ


1 Answers

Sounds like there's only one thread running, and so the rest of your script can't continue until the show function returns, which won't happen until the figure is closed. Should be relatively simple to call that show function in a newly created thread, which would allow the rest of your script to keep running. I'd look into the threading python module.

like image 188
DaveTheScientist Avatar answered Sep 17 '22 15:09

DaveTheScientist