|
Hi, Ok, I actually observe the same problem as you are having. Since I hardly use the interactive plotting mode I never came across this issue before. When I create figures in a loop I always save them directly to a .png and/or .eps file and watch them from there. This allows me to easily inspect many different figures while the script is still doing other stuff. It is important to note that this issue is not related to spyder, but two other factors (at least, that is what I think, but not that I am not a developer): 1) the loop in the script prevents the event loop to kick in and actually draw the figure (based on this: http://www.mail-archive.com/[email protected]/msg13375.html) 2) different matplotlib plotting backends deal with this differently, and maybe the Qt4Agg backend has some issues on this department (http://www.mail-archive.com/[email protected]/msg13383.html) My matplotlib backend is set to Qt4Agg. You can change the backend as follows (note that each backend comes with it own dependencies...): * directly in Spyder: Tools > Preferences > Console > External modules > Matplotlib GUI backend * matplotlib.use('backendname') (do this before importing pylab!), more info on the backends can be found here: http://matplotlib.sourceforge.net/faq/usage_faq.html#what-is-a-backend * in the matplotlib config file, but I'll ignore that here (http://matplotlib.sourceforge.net/users/customizing.html#customizing-matplotlib) I played a bit with the different backends, and adding two draw() statements behind each other, but it never got really better on my end. GTKAgg came close, but while the script is running the figures are not redrawn automatically (or something): when moving figure 2 over figure 1, figure 1 changed grey. import numpy as np import time import pylab as p a = np.arange(10) for x in xrange(3): p.figure() p.plot(a) p.draw() p.draw() p.show() time.sleep(2) Short term conclusion as far as I am concerned: if you want to browse through different figures that are made in a script and while the script is still running: save them to disc and watch from there. Note that if I execute the script in a "dedicated interpreter" (contrary to "current interpreter", you can change those settings by pressing F6 to see the "run configurations" for each script), the figure gets drawn correctly, but the scripts only advances after you closed the figure again. Disclaimer: I am not a developer so I only have limited knowledge on these matters. Regards, David On 02/03/12 18:04, Andrew Collette wrote: Hi,two changes that made it work for me:import numpy as np #import time import pylab as p a = np.arange(10) for x in xrange(5): p.figure() p.plot(a)I tried this, and it created ten empty windows one at a time, all of which are blank until the loop finishes. There's something about how the plot command works that doesn't actually draw anything until the script is over. ion() and p.draw() don't seem to do anything when put in the script. Andrew -- You received this message because you are subscribed to the Google Groups "spyder" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en. |
- [spyder] Plotting from a script or loop with spyder Andrew Collette
- [spyder] Re: Plotting from a script or loop with spyd... Jonatan Hjul
- Re: [spyder] Re: Plotting from a script or loop w... David Verelst
- Re: [spyder] Re: Plotting from a script or lo... Andrew Collette
- Re: [spyder] Re: Plotting from a script o... David Verelst
- [spyder] Re: Plotting from a script or loop with spyd... Chris
- Re: [spyder] Plotting from a script or loop with spyd... Pierre Raybaut
- Re: [spyder] Plotting from a script or loop with ... Andrew Collette
