>On Tue, Oct 13, 2009 at 5:06 PM, Laurent Dufr?chou

><laurent.dufrec...@gmail.com> wrote:
>> Hey, coparing on how GTK2 example is done I've seen a difference between the 
>> two!
>>
>> In QT4Agg example and WX example the code use:
>>
>> canvas.copy_from_bbox(ax.bbox)
>> replacing all occurrence of ax.bbox with ax.get_figure().bbox solved all the 
>> issue I add.
>>
>
>I'm not sure why using ax.bbox does not work, and it SHOULD work.
>Note that animation_blit_gtk.py DOES use ax.bbox.
>
>> Perhaps we should correct the examples.
>> I can send you the good working example if you want.
>
>If using ax.bbox does not work, than it is a bug (either mpl or the example).
>Unfortunately, this seems to happen only on windows.
>So, please file a bug report (again).
>
>Regards,
>
>-JJ
>

Hy guys,

Just saw your posts. I don't understand the business with the 
ax.get_figure().bbox.
I'm also using windows, and a modified version of the animation_blit_tk.py 
using imshow work fine for me.
I just checked whether the get_figure() changes anything and I get exactly the 
same result in terms of performance.
I attach the code below if it can be of any use.

Cheers,

Auré


# For detailed comments on animation and the techniqes used here, see
# the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations

import matplotlib
matplotlib.use('TkAgg')

import sys
import pylab as p
import matplotlib.numerix as nx
import time

from FileUtils10 import fileHandling

# for profiling
tstart = time.time()
tprevious = time.time()

fnamelist = ['....']

ax = p.subplot(111)
canvas = ax.figure.canvas

print 't1 ',time.time()-tprevious
tprevious = time.time()

# create the initial line
dataarr = fileHandling(fnamelist[0]).read()
#print dataarr.dtype
#dataarr = dataarr.astype('uint8')
print 't2 ',time.time()-tprevious
tprevious = time.time()

image = p.imshow(dataarr, animated=True)
print 't3 ',time.time()-tprevious
tprevious = time.time()

def run(*args):
    tprevious = time.time()
    background = canvas.copy_from_bbox(ax.bbox)
    print 't4 ',time.time()-tprevious
    tprevious = time.time()
    while 1:
        #print fnamelist[run.cnt]
        # restore the clean slate background
        canvas.restore_region(background)
        print 't5 ',time.time()-tprevious
        tprevious = time.time()
        # update the data
        dataarr = fileHandling(fnamelist[run.cnt]).readMCCD()
        dataarr *= run.cnt
        print 't6 ',time.time()-tprevious
        tprevious = time.time()
        image.set_data(dataarr)
        print 't7 ',time.time()-tprevious
        tprevious = time.time()
        # just draw the animated artist
        ax.draw_artist(image)
        print 't8 ',time.time()-tprevious
        tprevious = time.time()
        # just redraw the axes rectangle
        canvas.blit(ax.bbox)
        print 't9 ',time.time()-tprevious
        tprevious = time.time()

        if fnamelist[run.cnt] == fnamelist[-1]:
            # print the timing info and quit
            print 'total time:' , time.time()-tstart
            print 'FPS:' , 1000./(time.time()-tstart)
            p.close('all')
            sys.exit()

        run.cnt += 1
run.cnt = 0

 
p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
p.grid() # to ensure proper background restore
manager = p.get_current_fig_manager()
manager.window.after(100, run)

p.show()


      
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to