I’m currently writing a specialized image processing package using Matplotlib. The goal would be to let users use it interactively from an ipython console.
So I have some functions for selecting points on plots (via “button_press_event”), and others for data plotting (and also for data processing, of course). When the user calls a plotting or a point-selecting function, I have to call plt.show() at the end of it… but then this seems to do something irreversible which cannot be cancelled e.g. by plt.ioff(). But at the same time I can’t stay in show() mode forever, because if I did so, the program would fail when the user calls another point-selecting function (as the call to the point-selecting function becomes non-blocking, Python raises an error when the yet undefined coordinates are read in a following part of the enclosing function). (For the same reason, trying to use ipython -pylab leads to failure starting from the first call to a point-selecting function (instead of the second when using ipython).)
(And I can’t use plt.ginput as I sometimes want to update the plot using some home-made functions while the user selects data on it).
So I have to find a way of showing the plot(s) to the user, and still come back to pre- plt.show() mode after (of course, if there was a way to show the plots without calling plt.show(), that would work too)… I believe this is a “classic” question, but I haven’t found an answer to it. So does anyone have an idea about it?
Thanks in advance,