The Matplotlib make_axes_locatable allows make_axes_locatable to snap a new axis to the side of an existing axis. However, it resizes the parent axis. Is there any way to avoid this?
The following is a complete example showing the problem and how to reproduce it:
import matplotlib.pyplot as pl from mpl_toolkits.axes_grid import make_axes_locatable import matplotlib.axes as maxes fig = pl.figure() ax1=pl.subplot(1,3,1) ax1.imshow([[0,1],[2,0]]) ax1.yaxis.set_visible(False) ax1.xaxis.set_visible(False) ax2=pl.subplot(1,3,2) ax2.imshow([[0,1],[2,0]]) ax2.yaxis.set_visible(False) ax2.xaxis.set_visible(False) ax3=pl.subplot(1,3,3) ax3.imshow([[0,1],[2,0]]) ax3.yaxis.set_visible(False) ax3.xaxis.set_visible(False) pl.subplots_adjust(wspace=0) divider = make_axes_locatable(ax1) cax1 = divider.new_horizontal(size=0.2, pad=0.0, pack_start=True, axes_class=maxes.Axes) pl.colorbar(ax1.images[0],cax=cax1) cax1.yaxis.set_label_position('left') cax1.yaxis.set_ticks_position('left') fig.add_axes(cax1) divider = make_axes_locatable(ax2) cax2 = divider.new_vertical(size=0.2, pad=0.0, pack_start=True, axes_class=maxes.Axes) fig.add_axes(cax2) pl.colorbar(ax2.images[0],cax=cax2,orientation='horizontal')

The problem is that the subheadings now have different sizes. I think the left and right have contracted, but the middle has not changed.
source share