Jim Vickroy wrote:
Thanks for the detailed explanation; I may be starting to understand the
significance of *figure*.
I was hoping to avoid repeated calls like map.drawcoastlines(),
map.drawmapboundary(), map.drawmeridians(plot.arange(0,360,30)), and
map.drawparallels(plot.arange(-90,90,30)). So, I will follow your
example and experiment to see what works and what does not to better
understand the behaviors.
Hi Jim and others,
You should definitely reuse the basemap instance but from your reply it seems like you would also like to reuse the figure instance. The current figure instance is changed when you make plot commands like map.drawcountries(). What I do is to remove the stuff that should not be reused. That is something like this:
# If first time create figure from basemap using my function getfigure
if fig == None:
fig = getfigure(map)
# The figure I am plotting on has two axes which I change - an axes with the plot and an axes with a colorbar
ax = fig.get_axes()
cax = fig.get_axes()
# Create plot and save figure
cs = map.contourf(lon, lat, data, ax=ax)
fig.colorbar(cs, cax=cax, orientation='vertical', extend='both')
# Remove contourf axes ContourSets
for c in cs.collections:
# Remove colorbar axes ContourSets
cax.collections = 
Hope it helps.