On 2010-07-14 01:46:49 +0200, John Hunter said: > On Mon, Jul 12, 2010 at 5:06 PM, K.-Michael Aye > <kmichael....@gmail.com> wrote: >> On 2010-07-12 23:17:19 +0200, John Hunter said: >> >>> On Mon, Jul 12, 2010 at 4:06 PM, K.-Michael Aye >>> <kmichael....@gmail.com> wrote: >>>> Dear all, >>>> >>>> I'm not sure if this is by design or a problem: > > It's by design and is not a leak. matplotlib supports multiple images > on the same axes, and can composite multiple images that overlap the > same space using transparency, so each call to imshow is adding > additional data to the axes.
Understood, and of course quite useful. But see below. > You can inspect the ax.images list to > see the list of images is growing. > > If you have an Image object and want to remove it from the Axes, call > > im.remove() This worked. > or you can manipulate the list of ax.images directly, eg > > del ax.images[0] I tried this and got this error message: In [10]: del ax.images.remove[0] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/aye/Documents/workspace/pyrise_saver_clone/src/<ipython console> in <module>() TypeError: 'builtin_function_or_method' object does not support item deletion Here my history of that session: 1 : from fan_finder import get_data 2 : data = get_data(2) 3 : fig = figure() 4 : ax = fig.add_subplot(111) 5 : im = imshow(data) 6 : ax.images 7 : im = imshow(data) 8 : ax.images 9 : ax.images.remove[0] 10: del ax.images.remove[0] 11: hist% 12: _ip.magic("hist ") data is a np.array I found another funny thing: Even so i set hold(False), and the ax.images array does not increase, the memory consumption increases. I used these commands: 3 : fig = figure() 4 : ax = fig.add_subplot(111) 5 : imshow(data) 6 : ax.images 7 : hold(False) 8 : imshow(data) 9 : ax.images At step 6 I had 1 image in the ax.images array, at step 9 still only 1, but RealMem went up the approx same amount between 7 and 8 then it did between 4 and 5. > > or if you have a single image and want to update the data in it, you can do > > im = ax.imshow(something) > im.set_array(newdata) I am using this way in a GUI I programmed and works very well there. BR, Michael > > to update the array in the existing image. > > JDH > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users