From: Benjamin R. <ben...@ou...> - 2011-05-30 20:30:36
|
On Mon, May 30, 2011 at 3:11 PM, Eric O LEBIGOT (EOL) < Eri...@no...> wrote: > > > efiring wrote: > > > > Is it correct that you want interactive mode, except that you want to > > control when drawing occurs, for purposes of efficiency? > Thank you for your interest in this question, Eric! > > The goal is to indeed control when drawing occurs, but also to not use > show() (because it cumbersome to have to close umpteen windows so as to > finish a Matplotlib program that opened lots of figures). (I checked the > examples that you referred to) > > It looks like Matplotlib forces either to use the interactive mode > (possibly > inefficient) or to use show() (possibly cumbersome). I wish that > Matplotlib > offers an alternative to this situation, but this looks less and less to be > the case. That's something I would like to suggest to the devs. > :-) > 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). Furthermore, I think Eric Firing's point was that mpl is fully capable of doing what you want. The automatic draws are only done if the calls come through pyplot or pylab and if interactive mode is on. There might be a few minor exceptions to this rule, but those shouldn't cause significant overhead. If you call the drawing commands directly, then a refresh does not occur until you tell it to with a call to draw(). In pyplot, nearly all drawing commands have as the final step a call to a function called "draw_if_interactive()". This function does exactly what it says. Therefore, if you want interactive mode, but do not want a refresh after each pyplot command, then don't use the pyplot commands! Just use the objects' drawing commands (which is what pyplot calls). Also, note that matplotlib is hierarchical. 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. So, a figure object has (among other things) axes objects as children. An axes object has (among other things) various collection objects from the plotting commands as its children. Maybe a look at some of the animation examples might be a good way to illustrate this. I would suggest looking at the older animation examples on sourceforge where the internals are all laid out. I hope this is helpful, Ben Root |