I am new to matplotlib. When I generate a series of contourf plots with a loop, matplotlib creates n duplicated colorbars (the colorbar has a fixed range)
Must I destroy the old colorbar for each loop, if so how do I do that?
Update:
Ok, but if I generate a colorbar for a contourf plot. How do I make sure that the entire extent of the scale is included. I have tried using “clip=False” & extend=’both’
c_scale = matplotlib.colors.Normalize(vmin=0, vmax=1,clip=False)
cbar = plt.colorbar(cmap=plt.cm.jet,norm=c_scale,shrink=0.5,extend='both')
contourf does not generate a colorbar, colorbar does.
If the colorbar has a fixed range, you could call colorbar() once at the beginning and then merely plot your new contourf without calling colorbar()
An example: