From: Eric F. <ef...@ha...> - 2011-05-31 08:27:34
|
On 05/30/2011 09:59 PM, Eric O LEBIGOT (EOL) wrote: > > I really appreciate your continuing this discussion, Ben. > > Benjamin Root-2 wrote: >> >> On Mon, May 30, 2011 at 3:11 PM, Eric O LEBIGOT (EOL)< >> Eri...@no...> wrote: >> Question: would displaying a figure (or a group of figures), pausing to >> let >> you close them, and then continuing to the next figures more along the >> lines >> of what you want? That is certainly possible with matplotlib. Since >> v1.0.0, multiple calls to show() is allowed (although you may need v1.0.1 >> for certain backends to do this correctly). >> > Yeah, the new show() is nice. However, I don't want my users to have to > close the numerous opened figures one by one, even if it is done in 4 times > 3 clicks (and, again, it would not be convenient to put the graphs in > subplots). So, what I am really looking for is really: (1) display figures > without having to use show(); and (2) do this efficiently (without automatic > drawing through the interactive mode). > > > Benjamin Root-2 wrote: >> >> (…) In pyplot, nearly all >> drawing commands have as the final step a call to a function called >> "draw_if_interactive()". >> (…) >> You could call directly call >> draw() on each object you want re-drawn, but you don't have to. You can >> give a single call to a parent object that would call draw() for all of >> its >> children objects. >> (…) >> > Thank you for these more theoretical explanations, which are interesting. > > However, they do not seem to apply to Matplotlib 1.0.1 on Windows (default > backend), or 1.0.0 Mac OS X (default backend and GTKAgg). The main problem > is that draw() does unfortunately not draw anything in non-interactive mode > (this happens when there is no show() in the code)! So, with these two > recent version, in *non*-interactive mode, it does not appear that "a > refresh does not occur until you tell it to with a call to draw()", and > things like this. There is no refresh at all, and pyplot.draw() does > display anything (this is illustrated by the last program example I posted). > As far as I can see, theory and practice strongly clash, about the > "refreshing" effect of the draw() command (in non-interactive mode), as I > can't see anything being refreshed or displayed by draw. What is your take > on this? > > Thank you for the idea of bypassing pyplot's automatic update in interactive > mode. How is this done? Doing ax.draw(ax.figure.canvas.renderer) raises a > RunTime error with the default Mac OS X backend, and an AttributeError with > the GTKAgg backend. How should the draw() method of Matplotlib objects be > called? > > Now that I'm thinking of it, the crux of the problem might be that > pyplot.figure() does *not* open any window, in non-interactive mode (until > show() is called, which I want to avoid). This looks like a bad start if > draw() is to refresh anything… Could this be the main stumbling block? Can > a new window be opened in non-interactive mode (without using show())? Stop saying you want to avoid show(); let's just figure out how to get to the desired end result. You probably *need* to use show; with 1.0.1 in interactive mode, it will not block. Your script can close the windows; your user doesn't have to do so manually. It sounds like you are indeed talking about a free-standing script, that is, not involving ipython or other intermediate shell, correct? Can you come up with a minimal example of what you want it to do, and how you want the user to be able to interact with it? Does the attached script illustrate something roughly like what you are trying to do? Eric |