How to add Matplotlib Colorbar Ticks
A working example (for any value range) with five ticks along the bar is:
m0=int(np.floor(field.min())) # colorbar min value
m4=int(np.ceil(field.max())) # colorbar max value
m1=int(1*(m4-m0)/4.0 + m0) # colorbar mid value 1
m2=int(2*(m4-m0)/4.0 + m0) # colorbar mid value 2
m3=int(3*(m4-m0)/4.0 + m0) # colorbar mid value 3
cbar.set_ticks([m0,m1,m2,m3,m4])
cbar.set_ticklabels([m0,m1,m2,m3,m4])
Update the ticks and the tick labels:
cbar.set_ticks([mn,md,mx])
cbar.set_ticklabels([mn,md,mx])