def draw_colorbar(im, ax, fig):
divider = make_axes_locatable(ax)
cax = divider.append_axes('right', size='5%', pad=0.05)
fig.colorbar(im, cax=cax, orientation='vertical');
# example
fig = plt.figure(figsize=(10,3))
ax1 = fig.add_subplot(1, 2, 1)
im1 = ax1.imshow(map.T, cmap='jet')
draw_colorbar(im1, ax1, fig)