Hrafnkell Pálsson wrote:
> Any chance of further help?
> John?
>
> Hrafnkell
>   
Hrafnkell:  I'm pretty sure this is a fundamental limitation of 
canvas.restore_region - everything gets draw on top of it.

If I recall correctly, you'd like to save the map with coastlines drawn, 
and just redraw contours on it.  If you're reusing a Basemap instance, 
I'd be surprised if the time spent redrawing the coastlines is all that 
significant.  Are you?  Creating the coastline polygons in map 
projection coordinates is the most expensive operation, but that is done 
when the Basemap instance is created.

Another option would be to just remove the contours from the figure, 
then redraw the new ones and re-save the figure, i.e.

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# create new figure
fig=plt.figure()
# setup of of mollweide Basemap.
m = Basemap(resolution='c',projection='moll',lon_0=0)
# draw some contours.
x, y = m(lons, lats)  # get map projection coords of lat/lon grid
CS = m.contour(x,y,data,15,linewidths=0.5,colors='k')
# draw coastlines and projection limb.
m.drawcoastlines()
m.drawmapboundary()
# save figure with contours.
plt.savefig('fig1.png')

# remove contours, save figure again.
for coll in CS.collections:
    coll.remove()
plt.savefig('fig2.png')

# draw contours again, this time red, save figure a third time.
CS = m.contour(x,y,data,15,linewidths=0.5,colors='r')
plt.savefig('fig3.png')

HTH,

-Jeff

-- 
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : [EMAIL PROTECTED]
325 Broadway                Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg



-------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to