I'm trying to create a figure with 1 row and 3 columns and struggling with many things. For one, my subplots turn out to be really tiny little slivers and I get an error when trying to add a colorbar. How can I make the subplots be boxes and the colorbar show up on the far right?
rmax0, rmax1, and rmax2 all range between 0 and 700 (majority are less than 200) and fspd ranges between 0 and 10.
import matplotlib.pyplot as plt
import numpy as np
ax1 = plt.subplot(131)
nice = plt.get_cmap('BuPu')
bins1 = np.arange(0,700,700/50.0)
bins2 = np.arange(0,10,10/50.0)
h,xedges,yedges = np.histogram2d(rmax0,fspd,bins=[bins1,bins2],normed=True)
X,Y = np.meshgrid(xedges,yedges)
ax1.pcolormesh(X, Y, h,cmap=nice)
ax1.set_aspect('equal')
plt.xlim([0,200])
plt.ylim([0,10])
ax2 = plt.subplot(132)
h,xedges,yedges = np.histogram2d(rmax1,fspd,bins=[bins1,bins2],normed=True)
X,Y = np.meshgrid(xedges,yedges)
ax2.pcolormesh(X, Y, h,cmap=nice)
ax2.set_aspect('equal')
plt.xlim([0,200])
plt.ylim([0,10])
ax3 = plt.subplot(133)
h,xedges,yedges = np.histogram2d(rmax2,fspd,bins=[bins1,bins2],normed=True)
X,Y = np.meshgrid(xedges,yedges)
ax3.pcolormesh(X, Y, h,cmap=nice)
ax3.set_aspect('equal')
plt.xlim([0,200])
plt.ylim([0,10])
plt.colorbar()
plt.show()
When I add the plt.colorbar() line I get the following error: RuntimeError: No mappable was found to use for colorbar creation. First define a mappable such as an image (with imshow) or a contour set (with contourf).