xxxxxxxxxx
%%Original code
figure('position',[680 183 560 795])
h(1)=subplot(2,1,1)
imagesc(rand(1,3))
colorbar
h(2)=subplot(2,1,2)
imagesc(rand(3,3))
axis equal
axis tight
%%Add this section
pos{1} = plotboxpos(h(1))
pos{2} = plotboxpos(h(2))
NewPos=[pos{2}(1) pos{1}(2) pos{2}(3) pos{1}(4)]
set(h(1),'position',NewPos);