'How do i make a Colorbar propotional spacing-wise

What can I do to make a colorbar centered at any value i want and keep everything "proportional" still. i.e squish the side to be the 1-2 side to be the length of the 0-1

from matplotlib import colors
interval = np.hstack([np.linspace(0,1)])
colours = cmaps.NCV_jet(interval)) 
cm = LinearSegmentedColormap.from_list('name',colours, N=N)
cmap=cm 
norm= colors.TwoSlopeNorm(vmin=-2, vcenter=1, vmax=2)
contour = plt.pcolormesh(lon, lat, data,  cmap = cmap )
sm = plt.cm.ScalarMappable(norm=norm, cmap = contour.cmap)
sm.set_array([])
cb = plt.colorbar(sm,ticks=[-2,-1,0,1,2], orientation="horizontal",spacing='proportional', pad=0.0205)

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source