On 2013/08/23 3:55 AM, Kari Aliranta wrote:
> Hello, fellow Matplotlib users,
>
>
> I'm embedding some Matplotlib figures into GUI (PyQt4) windows or widget
> canvases using qt4agg as the backend. I'm having problems with these
> figures popping up any time when some other part of the program calls
> pyplot.show().

Generally, when embedding, one simply does not use the pyplot interface 
at all, so this sort of problem does not arise.  Is there any reason why 
you can't use this approach?
>
> How do you avoid this showing of previous figures? Is there some hidden
> buffer where the figures go? If there is, what is the way to clear this
> buffer, or preferably avoid putting figures in this buffer altogether?
> I'd be happy to handle these figures as simple individual objects.

To remove a figure created by pyplot, use pyplot.close(fig); but still, 
trying to use the pyplot interface for anything more complicated than 
direct interactive use and simple non-interactive scripts is likely to 
cause more problems than it solves. It's just not what pyplot is 
designed for.

Eric
>
> (I'm aware that this "hidden buffer" may be the pylab/pyplot buffer. I
> tried deepcopying the figure and then clearing the pylab buffer with
> pylab.clf() , but figures don't seem to be deepcopyable.)
>
>
> A  typical situation is the following:
>
> - There is a window with a widget. The widget (widgetMpl in the code
> below) has a slightly customized FigureCanvas in it. The drawing code is
> activated by clicking a button in the window. The code goes as follows.
>
>       # The plot method returns a complicated instance of Figure with
> several axes, constructed with Pylab.
>       previewFigure =
> self.parent.experiment.file_to_plot.plot(show=False, n_channels=10)
>
>       self.ui.widgetMpl.canvas.figure = previewFigure
>       self.ui.widgetMpl.canvas.draw()
>
>
> - I draw the figure in the window once, or several times with different
> file_to_plot, by pressing the button. I may or may not close the window
> with the aforementioned widget.
>
> - Elsewhere in the program there is another window with very simple
> drawing code using pyplot. When this code calls pyplot.show(), all the
> figures drawn in the first window will show up.
>
>
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to