function tightmap

%TIGHTMAP removes whitespace around a map
% 
%   TIGHTMAP sets the MATLAB axis limits to be tight around the map in the 
%   current axes.  This eliminates or reduces the white border between the 
%   map frame and the axes box.  Use AXIS AUTO to undo TIGHTMAP.
%   
%   See also PANZOOM, ZOOM, PAPERSCALE, AXESSCALE, PREVIEWMAP

% Copyright 1996-1998 by Systems Planning and Analysis, Inc. and The MathWorks, Inc.
% $Revision: 1.3 $  $Date: 1998/09/01 18:34:15 $


hframe = handlem('Frame');
newframe = 0;
if isempty(hframe)
	hframe = framem;
	newframe = 1;
end

xframe = get(hframe,'Xdata');
yframe = get(hframe,'Ydata');   

xlim([min(xframe(1:end-1)) max(xframe(1:end-1))]) % spurious zero at tend of frame?
ylim([min(yframe(1:end-1)) max(yframe(1:end-1))])

if newframe; delete(hframe); end  % to toggle state back to what it was

