[To summarize an off-list conversation -- Eric and I had been discussing
ways to speed up pcolor plots. After some improvements, quadmeshes are
still about a factor of 2 slower on the branch than on the trunk. His
use case often involves the simpler problem of rectilinear meshes, which
can be handled by NonUniformImage, which should be much faster in all
cases.]
Eric Firing wrote:
you might want
to look at the long-neglected but promising pcolor method in the
_image.cpp, used by the NonUniformImage class in image.py.
There is an example on using NonUniformImage in pcolor_nonuniform.py
that seems to work -- so this code isn't too neglected ;)
I suspect that the axes pcolor method should actually be using this if
the grid is rectilinear and using quadmesh otherwise.
Implementation wise (just to get something working), it was easier to
extend imshow to take two 1D-arrays X and Y which define a non-uniform
grid for the image. (My changes merely give NonUniformImage a pyplot
API, so the user doesn't have to do as much work as in the example.)
But if we think this functionality belongs with pcolor, it can be
exposed that way instead. However, there should be some way to let
pcolor know that the mesh is rectilinear. (It would otherwise be
wasteful computation just to determine that and proceed accordingly).
As expected, there are significant performance benefits:
Branch:
nonuniformimage:
init: 0.27
fps: 21.37
pcolormesh:
init: 0.42
fps: 2.61
Trunk:
nonuniformimage:
init: 0.25
fps: 22.52
pcolormesh:
init: 0.28
fps: 6.64
I've committed my changes on the transforms branch so you can play with
it -- I'm holding off on changing the trunk due to the pending release.
But if everyone agrees on the way to expose this, it would be nice to
merge this over to trunk before the release.
Cheers,
Mike
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
import numpy as npy
from numpy.random import rand
import matplotlib
from matplotlib.pyplot import pcolor, pcolormesh, savefig, show, ion, axis,
draw, axes, imshow
import time, sys
ion()
t = time.clock()
X = npy.arange(100)
X = X * X
Y = npy.arange(1000)
Y = Y * Y
imshow(rand(1000,100), X, Y)
print "init: ", time.clock() - t
frames = 25.0
t = time.clock()
for i in xrange(int(frames)):
part = (1.0 - (i / frames) / 2.0)
axes().set_ylim((0.0, 1000000.0 * part))
draw()
print "fps:", frames / (time.clock() - t)
show()
import numpy as npy
from numpy.random import rand
import matplotlib
from matplotlib.pyplot import pcolor, pcolormesh, savefig, show, ion, axis,
draw, axes, imshow
import time, sys
ion()
t = time.clock()
X = npy.arange(100)
X = X * X
Y = npy.arange(1000)
Y = Y * Y
pcolormesh(X, Y, rand(1000,100))
print "init: ", time.clock() - t
frames = 25.0
t = time.clock()
for i in xrange(int(frames)):
part = (1.0 - (i / frames) / 2.0)
axes().set_ylim((0.0, 1000000.0 * part))
draw()
print "fps:", frames / (time.clock() - t)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel