I found the answer to my question, resulting in the correct colorbar vs subplot spacing. Notice that if the spacing between subplot and colorbar does not matter, the answer of Molly is correct.
import numpy
import layout
import matplotlib.pylab as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
data = numpy.random.random((10, 10))
test = ["ax1", "ax2", "ax3", "ax4", "ax5", "ax6", "ax7", "ax8", "ax9"]
fig = plt.figure(1)
for idx in range(len(test)):
vars()[test[idx]] = fig.add_subplot(3, 3, (idx + 1))
divider = make_axes_locatable(vars()[test[idx]])
vars()["c" + test[idx]] = divider.append_axes("right", size = "5%", pad = 0.05)
im1 = ax1.imshow(data)
plt.colorbar(im1, cax = cax1)
im2 = ax2.imshow(data)
plt.colorbar(im2, cax = cax2)
im3 = ax3.imshow(data)
plt.colorbar(im3, cax = cax3)
im4 = ax4.imshow(data)
plt.colorbar(im4, cax = cax4)
im5 = ax5.imshow(data)
plt.colorbar(im5, cax = cax5)
im6 = ax6.imshow(data)
plt.colorbar(im6, cax = cax6)
im7 = ax7.imshow(data)
plt.colorbar(im7, cax = cax7)
im8 = ax8.imshow(data)
plt.colorbar(im8, cax = cax8)
im9 = ax9.imshow(data)
plt.colorbar(im9, cax = cax9)
plt.show()
This results in: