function L = newaxis(meshnod)
% L = newaxis(meshnod);
% Allows a rubberband box to be used to specify new axis
clf
zoom off
hold off

plot(meshnod(:,2),meshnod(:,3),'g.')
grid
title('click on lower left corner of new axis box and pull')
axis('equal')
[XY]=ginput(1);
rbbox([get(gcf,'currentpoint') 0 0],get(gcf,'currentpoint'))
[XY2]= get(gca,'currentpoint');
XY2 = XY2(1,1:2);


L = [XY(1) XY2(1) XY(2) XY2(2)];

if L(1)>L(2)
L(1) = XY2(1) ;
L(2) = XY(1);
end
if L(3)>L(4)
L(3) = XY2(2) ;
L(4) = XY(2);
end

hold on
plot([L(1) L(1) L(2) L(2) L(1)],[L(3) L(4) L(4) L(3) L(3)],'r:',...
     [L(1) L(1) L(2) L(2) L(1)],[L(3) L(4) L(4) L(3) L(3)],'r*')
hold off

% Force the new axis to have same shape as the window
%  The new axis is supposed be inside the choosen one.
pos = get(gcf,'position');
xpy = pos(3)/pos(4);
L4 = L(3)+(L(2)-L(1))/xpy;
L2 = L(1)+(L(4)-L(3))*xpy;
if(L4>L(4))
L(4) = L4;
else
L(2) = L2;
end
hold on
plot([L(1) L(1) L(2) L(2) L(1)],[L(3) L(4) L(4) L(3) L(3)])
hold off



