Hrafnkell Pálsson wrote: > > >> This will turn off the rendering of both the background rectangle as >> well as all the ticks and their associated labels, ticklines and >> gridlines. Perhaps Jeff can advise you vis-a-vis the basemap api what >> the equivalent is >> >> > > Ok, I tested your example and see what you mean. > But if I understood you correctly this won't allow me to retain the > watermark and the dots I've used for marking cities. > It would be nice if I could retain the whole background, if it wouldn't > matter whether I retrieved the background or actually plotted it. > But even just avoiding plotting the coastline every time would save a lot of > time. > > > > >> Perhaps Jeff can advise you vis-a-vis the basemap api what >> the equivalent is >> >> > > Could you, Jeff, give me a nudge in the right direction? I've read through > the basemap documentation but didn't notice anything that might help. > > Hrafnkell >
Hrafnkell: Had some time this morning, so I used John's method to create a working Basemap example: import matplotlib matplotlib.use('Agg') from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt # this example shows how to save a map background and # reuse it in another figure. # make sure we have all the same properties on all figs figprops = dict(figsize=(8,6), dpi=100, facecolor='white') # generate the first figure. fig1 = plt.figure(1,**figprops) ax1 = fig1.add_subplot(111) # create basemap instance, plot coastlines. map = Basemap(projection='moll',lon_0=0) map.drawcoastlines() map.drawmapboundary(fill_color='aqua') map.fillcontinents(color='coral',lake_color='aqua') fig1.canvas.draw() background = fig1.canvas.copy_from_bbox(fig1.bbox) fig1.savefig('figure1.png', dpi=100) # generate the second figure, re-using the background # from figure 1. fig2 = plt.figure(2,frameon=False,**figprops) ax2 = fig2.add_subplot(111, frameon=False, xticks=[], yticks=[]) # restore previous background. fig2.canvas.restore_region(background) # draw parallels and meridians on existing background. map.drawparallels(range(-90,90,30)) map.drawmeridians(range(-180,180,60)) fig2.savefig('figure2.png', dpi=100) I've added this to the basemap examples directory as save_background.py HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328 ------------------------------------------------------------------------- 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