function fixwidth(ax,leg)

axpos = get(ax,'position');
newpos = [0.04, axpos(2), axpos(3)+axpos(1)-0.04, axpos(4)];
set(ax,'position',newpos);

legpos = get(leg,'position');
set(leg,'position', ...
    [newpos(1)+newpos(3)+0.005, legpos(2) legpos(3)-0.01, legpos(4)])
