I'm looking for a simple way to scale a color bar so it will be the same
height as the image. It seems to work automatically if the image is at
least as tall as it is wide, but when it is wider than tall it seems to
scale to the width rather than height. (Shouldn't the default behavior
be to scale to height if the colorbar is vertical and width if its
horizontal?) One approach that I found at one point was something like
fig = plt.figure(figsize=(11,5))
cax = fig.add_axes([0.9,0.1,0.01,0.8]) # axes for colorbar
ax = plt.subplot(111)
im = ax.imshow(image)
but even with this method it seems that tweaking the figsize and
add_axes arguments. I've also fiddled with the shrink and fraction
keywords and have managed to get good results, but it seems so ad hoc.
Is there a better way?