Colormap.__call__ is slow

Hello all,

I'm creating a python application what does some calculation and displays the result as two imshow() with respective colorbars as the calculation progresses. Each array is ~8192x50. Updating the image is slow, so I only update every 2 seconds or so, but even doing this a significant part of the program's time is spent on Colormap.__call__ of colors.py. Another significant time sink is motion_notify_event of backend_gtk.py. A small example follows to illustrate the problem. Any ideia on how to circunvent or correct this?

Thank you,
Jo�o Lu�s Silva

···

----------------------------------------

import numpy as np
from numpy.random import rand
import pygtk
pygtk.require('2.0')
import gtk
import matplotlib
matplotlib.use('GTKAgg')
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
from matplotlib.figure import Figure

def main():
     N = 2000

     win = gtk.Window()
     vbox = gtk.VBox()
     fig = Figure()
     ax = fig.add_subplot(111)
     canvas = FigureCanvas(fig)
     im = ax.imshow(rand(N,N),origin='lower',aspect='auto',extent=(0.0,1.0,0.0,1.0),interpolation='bilinear')
     cb = fig.colorbar(im)
     vbox.pack_start(canvas)
     win.add(vbox)
     win.connect("destroy", lambda x: gtk.main_quit())
     win.show_all()
     gtk.main()

if __name__ == '__main__':
     #Use hotshot2calltree and kcachegrind to see the stats
     import hotshot
     prof = hotshot.Profile("hotshot_stats")
     prof.runcall(main)
     prof.close()

João Luís Silva wrote:

Hello all,

I'm creating a python application what does some calculation and displays the result as two imshow() with respective colorbars as the calculation progresses. Each array is ~8192x50. Updating the image is slow, so I only update every 2 seconds or so, but even doing this a significant part of the program's time is spent on Colormap.__call__ of colors.py. Another significant time sink is motion_notify_event of backend_gtk.py. A small example follows to illustrate the problem. Any ideia on how to circunvent or correct this?

Some time in the last year I made changes in mpl and in numpy to speed this up (the colormapping). What versions of mpl and numpy are you using?

Eric

···

Thank you,
João Luís Silva

----------------------------------------

import numpy as np
from numpy.random import rand
import pygtk
pygtk.require('2.0')
import gtk
import matplotlib
matplotlib.use('GTKAgg')
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
from matplotlib.figure import Figure

def main():
     N = 2000

     win = gtk.Window()
     vbox = gtk.VBox()
     fig = Figure()
     ax = fig.add_subplot(111)
     canvas = FigureCanvas(fig)
     im = ax.imshow(rand(N,N),origin='lower',aspect='auto',extent=(0.0,1.0,0.0,1.0),interpolation='bilinear')
     cb = fig.colorbar(im)
     vbox.pack_start(canvas)
     win.add(vbox)
     win.connect("destroy", lambda x: gtk.main_quit())
     win.show_all()
     gtk.main()

if __name__ == '__main__':
     #Use hotshot2calltree and kcachegrind to see the stats
     import hotshot
     prof = hotshot.Profile("hotshot_stats")
     prof.runcall(main)
     prof.close()

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Eric Firing wrote:

Some time in the last year I made changes in mpl and in numpy to speed this up (the colormapping). What versions of mpl and numpy are you using?

Eric

Sorry, I was still using matplotlib 0.91.4 (numpy 1.1.0). I upgraded to 0.98.3 and now the Colormap.__call__ is 5 times faster and no longer a problem. motion_notify_event of backend_gtk.py still takes much more time than it should, but I haven't looked into that, and anyway, my application runs fast enough now.

Thanks,
Jo�o Lu�s Silva