I want to have two plots be the same width, however the resulting code shrinks the imshow plot.
xx = np.linspace(0.0,255.5,512)
yy = np.linspace(0.0,255.5,512)
Func = np.random.rand(len(xx),len(yy))
f, axarr = plt.subplots(2,1)
f.tight_layout()
im = axarr[0].imshow(Func, cmap = 'jet', interpolation = 'lanczos',origin = 'lower')
pos = axarr[0].get_position()
colorbarpos = [pos.x0+1.05*pos.width,pos.y0,0.02,pos.height]
cbar_ax = f.add_axes(colorbarpos)
cbar = f.colorbar(im,cax=cbar_ax)
axarr[1].plot(xx,Func[:,255],yy,Func[255,:])
plt.show()
plt.close('all')
EDIT: I would also like to keep imshow's plot from looking stretched (essentially, I need the width and length stretched appropriately so the aspect ratio's are still equal).



aspect='auto'to the parameters ofimshow.