Re : Re: Little issue with blitting

Hi Laurent,

I think I might have found a way to solve your problem: instead of creating your axes using pylab.suplot, you should create the axes using the class way. I modified your code below and it works fine without loosing speed in the frame rate. Only thing is, I have no clue as to what is really the underlying problem… my best guess is that there is a conflict between pylab and the general class. I very rearely use pylab directly unless the problem is really simple, because I saw several posts mentioning possible conflicts.

Hope this helps you.

Cheers,

Aurélien

···

import sys
import pylab as p
import matplotlib as mpl
import numpy as npy
import time

fig = p.figure(figsize=(8.,4.))

#ax = p.subplot(212)
ax =
fig.add_axes((.05,.55,.9,.4))
#ax2 = p.subplot(211)
ax2 = fig.add_axes((.05,.05,.9,.4))

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)
#line, = p.plot(x, npy.sin(x), animated=True, lw=2)
line, = ax.plot(x, npy.sin(x), animated=True, lw=2)
line2, = ax2.plot(x, npy.cos(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)
background2 = canvas.copy_from_bbox(ax2.bbox)

# for profiling
tstart = time.time()
while 1:

    # restore the clean slate background
    canvas.restore_region(background)
    canvas.restore_region(background2)

     # update the

data
line.set_ydata(npy.sin(x+run.cnt/10.0))
line2.set_ydata(npy.cos(x+run.cnt/10.0))

    # just draw the animated artist
    ax.draw_artist(line)
    ax2.draw_artist(line2)

    # just redraw the axes rectangle
    canvas.blit(ax.bbox)
    canvas.blit(ax2.bbox)
    #canvas.blit(ax.get_figure().bbox)

    if run.cnt==100:

        # print the timing info and quit
         print 'FPS:' ,

100/(time.time()-tstart)

        #return
        sys.exit()

    run.cnt += 1

run.cnt = 0

#no need for the following since it is done directly when creating the axes
#p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs

#p.grid() # to ensure proper background restore
ax.grid() # to ensure proper background restore
ax2.grid() # to ensure proper background restore

manager = p.get_current_fig_manager()

manager.window.after(100, run)

p.show()


Message: 2
Date: Thu, 15 Oct 2009 18:40:22 +0200
From: Laurent
Dufr?chou <laurent.dufrechou@…287…>
Subject: Re: [Matplotlib-users] [Solved] Little issue with blitting
technique
To: ‘Aur? Gourrier’ <aurelien.gourrier@…136…>,
matplotlib-users@lists.sourceforge.net
Message-ID: <4ad7507f.0a1ad00a.018e.ffff84c1@…2082…>
Content-Type: text/plain; charset=“iso-8859-1”

Hi Aur?,

Taking this example (FPS is computed at the end of the loop each 100
frames):

(this is the same
example as you but not using FileUtils10)

################################################

import sys

import pylab as p

import numpy as npy

import time

ax2 = p.subplot(212)

ax = p.subplot(211)

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)

line, = p.plot(x, npy.sin(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)

# for profiling

tstart = time.time()

while 1:

    # restore the clean slate background

    canvas.restore_region(background)

    # update the data

    line.set_ydata(npy.sin(x+run.cnt/10.0))

     # just

draw the animated artist

    ax.draw_artist(line)

    # just redraw the axes rectangle

    canvas.blit(ax.bbox)

    if run.cnt==100:

        # print the timing info and quit

        print 'FPS:' , 100/(time.time()-tstart)

        return

    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()

################################################

This example will work on my machine @99FPS.

Now replace:

ax2
= p.subplot(212)

ax = p.subplot(211)

with:

ax = p.subplot(212)

ax2 = p.subplot(211)

The image is buggy because the blitting is no more working, still I get
86FPS. So let say no change.

Now replace ?ax.bbox? with ?ax.get_figure().bbox?:

The bug disappear and I get a small 20 FPS?

Tested under windows vista , matplotlib 0.99.1, python 2.5.4.

Laurent

Ps: I think ax.getFigure().bbox is getting the whole picture so this is why
it is slower.

De : Aur? Gourrier [mailto:aurelien.gourrier@…136…]
Envoy? : jeudi 15 octobre 2009 10:32
? : matplotlib-users@lists.sourceforge.net
Objet : Re:
[Matplotlib-users] [Solved] Little issue with blitting technique

On Tue, Oct 13, 2009 at 5:06 PM, Laurent Dufr?chou ><laurent.dufrechou@…287…> 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()

-------------- next part

An HTML attachment was scrubbed…



Come build with us! The BlackBerry® 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

End of Matplotlib-users Digest, Vol 41, Issue 51


Hello Auré and Jae-joon,

Hi all,

First thx for you help.

I’ve taken your example, modified a little to use QT loop. (it
was not working on my machine manager.window.after(100, run) was unknown)

The bad thing is that first it didn’t work BUT I’ve almost found
why.

If I call two times blit only one figure was drawn L

First I’ve tried to compute a bbox myself that was the size of
the addition of two figures bbox.

It worked.

Next I modified the Qtimer from 0 to 100.

And it worked (slower) but it worked.

So there is something missing like an event not posted or
something like this.

Any GUI guru help welcomed, I’ll dig this further, but I think
something is missing there.

Perhaps I should force a repaint of the widget immediately?

Anyway, I’m near the end J

Cheers,

Laurent

animation_blit_qt4_v3.py (3.56 KB)

···

De : Auré Gourrier [mailto:aurelien.gourrier@…136…]
Envoyé : mercredi 21 octobre 2009 13:55
À : matplotlib-users@lists.sourceforge.net
Cc : Laurent Dufr?chou
Objet : Re : Re: Little issue with blitting

Hi Laurent,

I think I might have found a way to solve your problem: instead of creating
your axes using pylab.suplot, you should create the axes using the class way. I
modified your code below and it works fine without loosing speed in the frame
rate. Only thing is, I have no clue as to what is really the underlying
problem… my best guess is that there is a conflict between pylab and the
general class. I very rearely use pylab directly unless the problem is really
simple, because I saw several posts mentioning possible conflicts.

Hope this helps you.

Cheers,

Aurélien


import sys
import pylab as p
import matplotlib as mpl
import numpy as npy
import time

fig = p.figure(figsize=(8.,4.))

#ax = p.subplot(212)
ax = fig.add_axes((.05,.55,.9,.4))
#ax2 = p.subplot(211)
ax2 = fig.add_axes((.05,.05,.9,.4))

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)
#line, = p.plot(x, npy.sin(x), animated=True, lw=2)
line, = ax.plot(x, npy.sin(x), animated=True, lw=2)
line2, = ax2.plot(x, npy.cos(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)
background2 = canvas.copy_from_bbox(ax2.bbox)

# for profiling
tstart = time.time()
while 1:

    # restore the clean slate background
    canvas.restore_region(background)
    canvas.restore_region(background2)

    # update the data

line.set_ydata(npy.sin(x+run.cnt/10.0))

line2.set_ydata(npy.cos(x+run.cnt/10.0))

    # just draw the animated artist
    ax.draw_artist(line)
    ax2.draw_artist(line2)

    # just redraw the axes rectangle
    canvas.blit(ax.bbox)
    canvas.blit(ax2.bbox)
    #canvas.blit(ax.get_figure().bbox)

    if run.cnt==100:

        # print the

timing info and quit
print ‘FPS:’
, 100/(time.time()-tstart)

        #return
        sys.exit()

    run.cnt += 1

run.cnt = 0

#no need for the following since it is done directly when creating the axes
#p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs

#p.grid() # to ensure proper background restore
ax.grid() # to ensure proper background restore
ax2.grid() # to ensure proper background restore

manager = p.get_current_fig_manager()

manager.window.after(100, run)

p.show()


Message: 2
Date: Thu, 15 Oct 2009 18:40:22 +0200
From: Laurent Dufr?chou <laurent.dufrechou@…287…>
Subject: Re: [Matplotlib-users] [Solved] Little issue with blitting
technique
To: ‘Aur? Gourrier’ <aurelien.gourrier@…136…>,
matplotlib-users@lists.sourceforge.net
Message-ID: <4ad7507f.0a1ad00a.018e.ffff84c1@…2082…>
Content-Type: text/plain; charset=“iso-8859-1”

Hi Aur?,

Taking this example (FPS is computed at the end of the loop each 100
frames):

(this is the same example as you but not using FileUtils10)

################################################

import sys

import pylab as p

import numpy as npy

import time

ax2 = p.subplot(212)

ax = p.subplot(211)

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)

line, = p.plot(x, npy.sin(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)

# for profiling

tstart = time.time()

while 1:

    # restore the clean slate background

    canvas.restore_region(background)

    # update the data

    line.set_ydata(npy.sin(x+run.cnt/10.0))

    # just draw the animated artist

    ax.draw_artist(line)

    # just redraw the axes rectangle

    canvas.blit(ax.bbox)

    if run.cnt==100:

        # print the timing info and quit

        print 'FPS:' ,

100/(time.time()-tstart)

        return

    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()

################################################

This example will work on my machine @99FPS.

Now replace:

ax2 = p.subplot(212)

ax = p.subplot(211)

with:

ax = p.subplot(212)

ax2 = p.subplot(211)

The image is buggy because the blitting is no more working, still I get
86FPS. So let say no change.

Now replace ?ax.bbox? with ?ax.get_figure().bbox?:

The bug disappear and I get a small 20 FPS?

Tested under windows vista , matplotlib 0.99.1, python 2.5.4.

Laurent

Ps: I think ax.getFigure().bbox is getting the whole picture so this is why
it is slower.

De : Aur? Gourrier [mailto:aurelien.gourrier@…136…]

Envoy? : jeudi 15 octobre 2009 10:32
? : matplotlib-users@lists.sourceforge.net
Objet : Re: [Matplotlib-users] [Solved] Little issue with blitting technique

On Tue, Oct 13, 2009 at 5:06 PM, Laurent Dufr?chou ><laurent.dufrechou@…878…287…> 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()

-------------- next part --------------
An HTML attachment was scrubbed…



Come build with us! The BlackBerry® 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

End of Matplotlib-users Digest, Vol 41, Issue 51


Ha, ok finally i’ve solved the issue.

In fact each time you call blit method you must force a repaint.

This what v4 does.

I’ve also removed self.repaint() in my script and modified
backend_qt4agg:

def blit(self, bbox=None):

“”"

Blit the region in bbox

“”"

self.replot = bbox

l, b, w, h = bbox.bounds

t = b + h

    #self.update(l, self.renderer.height-t, w, h) ß before

self.repaint(l, self.renderer.height-t, w, h)

And it work like a charm.

I got 72 FPS that it way better than the old 7 FPS I go without
blitting.

I’m not sure it is the ideal solution.

Any thought?

Laurent

animation_blit_qt4_v4.py (2.93 KB)

···

De : Auré Gourrier
[mailto:aurelien.gourrier@…136…]
Envoyé : mercredi 21 octobre 2009 13:55
À : matplotlib-users@lists.sourceforge.net
Cc : Laurent Dufr?chou
Objet : Re : Re: Little issue with blitting

Hi Laurent,

I think I might have found a way to solve your problem: instead of creating
your axes using pylab.suplot, you should create the axes using the class way. I
modified your code below and it works fine without loosing speed in the frame
rate. Only thing is, I have no clue as to what is really the underlying
problem… my best guess is that there is a conflict between pylab and the
general class. I very rearely use pylab directly unless the problem is really
simple, because I saw several posts mentioning possible conflicts.

Hope this helps you.

Cheers,

Aurélien


import sys
import pylab as p
import matplotlib as mpl
import numpy as npy
import time

fig = p.figure(figsize=(8.,4.))

#ax = p.subplot(212)
ax = fig.add_axes((.05,.55,.9,.4))
#ax2 = p.subplot(211)
ax2 = fig.add_axes((.05,.05,.9,.4))

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)
#line, = p.plot(x, npy.sin(x), animated=True, lw=2)
line, = ax.plot(x, npy.sin(x), animated=True, lw=2)
line2, = ax2.plot(x, npy.cos(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)
background2 = canvas.copy_from_bbox(ax2.bbox)

# for profiling
tstart = time.time()
while 1:

    # restore the clean slate background
    canvas.restore_region(background)
    canvas.restore_region(background2)

    # update the data

line.set_ydata(npy.sin(x+run.cnt/10.0))
line2.set_ydata(npy.cos(x+run.cnt/10.0))

    # just draw the animated artist
    ax.draw_artist(line)
    ax2.draw_artist(line2)

    # just redraw the axes rectangle
    canvas.blit(ax.bbox)
    canvas.blit(ax2.bbox)
    #canvas.blit(ax.get_figure().bbox)

    if run.cnt==100:

        # print the

timing info and quit
print ‘FPS:’
, 100/(time.time()-tstart)

        #return
        sys.exit()

    run.cnt += 1

run.cnt = 0

#no need for the following since it is done directly when creating the axes
#p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs

#p.grid() # to ensure proper background restore
ax.grid() # to ensure proper background restore
ax2.grid() # to ensure proper background restore

manager = p.get_current_fig_manager()

manager.window.after(100, run)

p.show()


Message: 2
Date: Thu, 15 Oct 2009 18:40:22 +0200
From: Laurent Dufr?chou <laurent.dufrechou@…287…>
Subject: Re: [Matplotlib-users] [Solved] Little issue with blitting
technique
To: ‘Aur? Gourrier’ <aurelien.gourrier@…136…>,
matplotlib-users@lists.sourceforge.net
Message-ID: <4ad7507f.0a1ad00a.018e.ffff84c1@…2082…>
Content-Type: text/plain; charset=“iso-8859-1”

Hi Aur?,

Taking this example (FPS is computed at the end of the loop each 100
frames):

(this is the same example as you but not using FileUtils10)

################################################

import sys

import pylab as p

import numpy as npy

import time

ax2 = p.subplot(212)

ax = p.subplot(211)

canvas = ax.figure.canvas

create the initial line

x = npy.arange(0,2*npy.pi,0.01)

line, = p.plot(x, npy.sin(x), animated=True, lw=2)

def run(*args):

background = canvas.copy_from_bbox(ax.bbox)

# for profiling

tstart = time.time()

while 1:

    # restore the clean slate background

    canvas.restore_region(background)

    # update the data

    line.set_ydata(npy.sin(x+run.cnt/10.0))

    # just draw the animated artist

    ax.draw_artist(line)

    # just redraw the axes rectangle

    canvas.blit(ax.bbox)

    if run.cnt==100:

        # print the timing info and quit

        print 'FPS:' ,

100/(time.time()-tstart)

        return

    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()

################################################

This example will work on my machine @99FPS.

Now replace:

ax2 = p.subplot(212)

ax = p.subplot(211)

with:

ax = p.subplot(212)

ax2 = p.subplot(211)

The image is buggy because the blitting is no more working, still I get
86FPS. So let say no change.

Now replace ?ax.bbox? with ?ax.get_figure().bbox?:

The bug disappear and I get a small 20 FPS?

Tested under windows vista , matplotlib 0.99.1, python 2.5.4.

Laurent

Ps: I think ax.getFigure().bbox is getting the whole picture so this is why
it is slower.

De : Aur? Gourrier [mailto:aurelien.gourrier@…136…]

Envoy? : jeudi 15 octobre 2009 10:32
? : matplotlib-users@lists.sourceforge.net
Objet : Re: [Matplotlib-users] [Solved] Little issue with blitting technique

On Tue, Oct 13, 2009 at 5:06 PM, Laurent Dufr?chou ><laurent.dufrechou@…878…287…> 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()

-------------- next part --------------
An HTML attachment was scrubbed…



Come build with us! The BlackBerry® 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

End of Matplotlib-users Digest, Vol 41, Issue 51