On Fri, 02 Nov 2012 16:45:22 +0100,
<mat...@li...> wrote:
> Message: 5
> Date: Fri, 2 Nov 2012 12:01:35 +0100
> From: Vlastimil Brom <vla...@gm...>
> Subject: Re: [Matplotlib-users] Figures piling up in Tkinter GUI
> (1.2.0rc2)
> To: mat...@li...
> Message-ID:
> <CAH...@ma...>
> Content-Type: text/plain; charset=ISO-8859-1
> 2012/11/1 Hans Bering <han...@ar...>:
>> Hello everybody,
>>
>> I'm building a small Tkinter GUI using matplotlib, in which I have to
>> change/update plots quite often depending on user input (with different
>> contents & sizes, in different places in the GUI, etc.; but always only
>> one figure at a time).
>>
>> As a first resort, I regenerated the figures with plt.figure(...)
>> whenever necessary; unfortunately, the program happily accumulated
>> memory with
>> every new figure until the computer would no longer cooperate in a
>> timely fashion. The following minimal script should demonstrate the
>> tendency:
>>
> ...
>
> Hi,
> I'd recommend to use an embedded plot and only clear and replace its
> content [...]
> I only roughly adapted that source to use your function and the memory
> usage appears to be more effective (although there is some increase
> too - as displayed in Process Explorer). Would some variation of the
> following work for you?
[...]
Hi Vlastimil,
thanks for your effort; I had tried the approach of clearing & replacing
the plot myself, too. Unfortunately, that approach has a different
problem: Because of the figure's size, I have to present it with
scrollbars, and clearing & reusing the plot does not seem to work when
resizing & scrolling the plot. I had posted that problem as a question at
Stackoverflow (as http://stackoverflow.com/questions/13197469 ), since I
hoped it might be "easier"; i.e., just a misunderstanding on my part of
how to wire together the scrollbars/canvas/figure. Please note that, while
I also use plt.figure(...) in the post at Stackoverflow, the effect
remains the same when using Figure(...) and ax.plot(...).
So basically I'm stuck between a rock and a hard place - I can either have
the memory issue reported previously; or the plot won't behave properly
with scrolling+resizing.
I am wondering: Should repeatedly creating Figures in a Tkinter GUI work,
and could this be a Matplotlib bug worth mentioning on some bug tracker?
Thanks & Regards
Hans
|