I'm trying to add a colorbar to a plot consisting of two subplots with equal aspect ratios, i.e. with set_aspect('equal')
:
The code used to create this plot can be found in this IPython notebook.
The image created using the code shown below (and here in the notebook) is the best result I could get, but it is still not quite what I want.
plt.subplot(1,2,1)
plt.pcolormesh(rand1)
plt.gca().set_aspect('equal')
plt.subplot(1,2,2)
plt.pcolormesh(rand2)
plt.gca().set_aspect('equal')
plt.tight_layout()
from mpl_toolkits.axes_grid1 import make_axes_locatable
divider = make_axes_locatable(plt.gca())
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(cax=cax)
This question seems related: