|
From: Slavin, J. <js...@cf...> - 2014-12-11 19:19:07
|
Hi, I'm trying to make a plot with four panes (2x2). The two on top are images, created with pcolormesh, while the ones on the bottom are line plots. I'd like to the axes to line up -- which they do -- but when I add a colorbar to the top right, it steals space from the image plot. I only need one colorbar since the two images are forced to have the same scaling. Can anyone tell me how to insert the colorbar on the top right without it taking space from the top right image -- or force the space to be taken from the horizontal space of all the plots so the shapes are uniform? I've tried several approaches including using make_axes_locatable from mpl_toolkits.axes_grid1 with no success. I must admit that I don't really understand what make_axes_locatable does, so it may be entirely the wrong thing to use. On the other hand, not using it, i.e. just using plt.colorbar or fig.colorbar seems to do essentially the same thing, steal space from the axes. The basics of the plot are like this: x = np.arange(20.) xc = (x[:-1] + x[1:])/2. y = np.arange(15.) xx,yy = np.meshgrid(x,y) z1 = np.random.randn(14,19) z2 = np.random.randn(14,19) fig,ax = plt.subplots(2,2) pc = ax[0,0].pcolormesh(x,y,z1) ax[1,0].plot(xc,z1[0,:]) ax[0,1].pcolormesh(x,y,z2) ax[1,1].plot(xc,z2[0,:]) cb = plt.colorbar(pc, ax=ax[0,1]) plt.show() Any help would be appreciated. Regards, Jon -- ________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA js...@cf... 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 fax: (617) 496-7577 USA ________________________________________________________ |