Glenn,

The slowness is almost entirely in the line

    rgba = lut[xa]

where lut is a 2-D uint8 table and xa is an array of indices.

I have replaced that in svn with

    rgba = lut.take(xa, axis=0)

which cuts the time in half!

That is still not nearly as fast as the solution you have found.  It 
should be possible to approach it by putting in a little extension code 
that optimizes the body of the __call__ method.  And for me at least, 
that would be easiest to do with pyrex.  Until a decision is made to use 
pyrex/cython in core matplotlib, however, this will have to wait.

Another approach would be to look for ways to speed up fancy indexing in 
numpy.  That would probably be very difficult, but could also be very 
rewarding if successful.

Eric

G Jones wrote:
> Numpy 1.0.3 and MPL 0.91.2. The image array is 256 x 1024. I found I
> could speed things up a lot (~15ms update time) by setting my data to
> be a 256 x 1024 x 4 array of uint8, so I guess the solution is to
> handle color mapping myself. I appreciate any other suggestions.
> Glenn
> 
> On 4/15/08, Eric Firing <[EMAIL PROTECTED]> wrote:
>> Glenn,
>>
>>  What version of numpy are you using?  What version of matplotlib? And what
>> are the dimensions of your image array?
>>
>>  Eric
>>
>>
>>  G Jones wrote:
>>
>>> Thank you for the suggestion.
>>> I now have the update time down to about 70 ms.
>>> When I run the code through the profiler, I see that each plot update
>>> requires a call to matplotlib.colors.Colormap.__call__,
>> and each of
>>> these calls takes 52 ms, 48 ms of which is spent inside the function
>>> itself. This looks like it is the bulk of the delay, so if I can
>>> optimize the Colormap.__call__ function, the performance should be
>>> much improved. Unfortunately I cannot seem to get finer grained
>>> information about what exactly is taking so long inside this function.
>>> Can anyone provide any hints?
>>> Thanks,
>>> Glenn
>>>
>>> On Sat, Apr 12, 2008 at 7:02 PM, hjc520070 <[EMAIL PROTECTED]> wrote:
>>>
>>>>  I just use blit on imshow map, and work properly. Maybe the following
>> code
>>>>  will help you.
>>>>
>>>>  def ontimer()
>>>>       canvas.restore_region(background)
>>>>       im.set_array(Z)
>>>>       ax.draw_artist(self.imList[i])
>>>>       canvas.blit(ax.bbox)
>>>>       canvas.gui_repaint()
>>>>  --
>>>>  View this message in context:
>> http://www.nabble.com/speeding-up-imshow-tp16623430p16656693.html
>>>>  Sent from the matplotlib - users mailing list archive at Nabble.com.
>>>>


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to