I am trying to create several images in a series using matplotlib and basemap. Essentially, I am trying to take meteorological model output data and make a plot of it at every timestep. However, I'm trying to do so efficiently and without clearing the figure and redrawing everything (especially the basemap things) at every timestep. Below is the relevant code.
basem = Basemap(llcrnrlon=setlats[1], llcrnrlat=setlats[0],
urcrnrlon=setlats[3], urcrnrlat=setlats[2],
projection='mill', resolution='l')
...
x,y = basem(lons, lats)
basem.drawcoastlines()
parallels = np.arange(0.,92,10.)
basem.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(180.,360.,10.)
basem.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
basem.drawstates()
basem.drawcountries()
cs = basem.contourf(x,y, plotted_var, levels=clevs,
cmap = plt.get_cmap(colorbar), extend="max")
cl = basem.contour(x,y, contoured_var, levels=clevsl, colors='k')
cb = basem.barbs(x[points],y[points],
barbs_var_u[points], barbs_var_v[points],
barbcolor='k',flagcolor='k', pivot='middle',
length=4)
...
for time in range(time+1,maxt+1):
timef = time
plotted_var = multf(np.array(data2[var])[timef,\
bounds[0]:bounds[1],bounds[2]:bounds[3]])
if barbs >=0 or barbs ==-2:
cb[0].set_UVC(barbs_var_u[points], barbs_var_v[points])
cs.set_array(plotted_var)
cl.set_array(contoured_var)
...
However, while this changes the barbs, it does not change the contours (either filled or not filled). I'm fairly certain that set_array is not the command I want to use, but I have looked in depth and can't find the set_uvc equivalent. In addition, I have also tried to ravel plotted_var and contoured_var and that also doesn't change. Note: I am only trying to update the z component (colors) of the contoured plot, the x and y need to stay the same.