Hello All,
Running:
- Windows Vista
- Python 2.6
- Matplotlib 0.99.3
The following script using draw() in matplotlib seems to work all right until almost anything momentarily interferes with the plot window.
import pylab as p
import time
try:
p.ion()
fig = p.figure()
subplt = fig.add_subplot(111, aspect='equal')
subplt.set_title('Test')
i = 1
while True:
if i % 20 == 0:
subplt.clear()
subplt.set_title('Test')
subplt.plot([50],[50+(i%20)],'ob')
subplt.set_xlim(40,60)
subplt.set_ylim(40,80)
p.draw() # ion should make this redundant, but does not draw without it
i += 1
time.sleep(0.1)
print '.'
except:
raise
finally:
fig.close()
If I touch the window or it goes out-of-focus at any point, it stops responding and hangs. Any code being executed will still continue running, but the plot window will remain in a hanged state. Why is this happening and is there a way to fix it? Also, if this is not occuring on your machine, can you list what platform you are running, etc. Apologies if I am missing something obvious here, and thanks for any help.
Semi-Related Questions:
- http://stackoverflow.com/questions/2604119/matplotlib-pyplot-pylab-not-updating-figure-while-isinteractive-using-ipython
- http://www.mail-archive.com/[email protected]/msg01283.html
Update:
I am still not sure what is causing this issue. I realized I could still solve the specific problem I was working on by switching over to pygtk. I am still interested in any answers if anyone has any.
Thanks.