You might try substituting "ax.pcolorfast(data)" for "ax.pcolormesh(data)". It is much faster and uses less memory, unless you specify a non-rectilinear grid, in which case it falls back on the quadmesh code behind pcolormesh.

pcolorfast is a unification of slightly modified code from image, NonUniformImage, and quadmesh. It is tagged as "experimental" because it may need some API tweaks, and maybe a different name. It is not yet exposed via pyplot or pylab interfaces.

The API is similar but not identical to that for pcolormesh; read the docstring (and code if necessary) for details.