Question

I'm using matplotlibs basemap to plot some wind barbs on top of a pcolor over multiple days using a loop. I can easily change the pcolor by using set_data() but now I'm not sure how to replace the barbs.

Is there a way to just remove the barbs without clearing the entire figure?

Was it helpful?

Solution

When you create the barbs object save the reference it returns and use it's remove function when you are done with it. The draw forces the canvas to re-draw with out the barbs. Assume that m is the basemap object.

 barbs1,barbs2 = m.barbs(...)
 # some code
 barbs1.remove()
 barbs2.remove()
 plt.draw()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top