function blankpol = mkpol(x,p,u,margin)
 
if nargin == 3, margin = 0.1; end


[nr,nc] = size(u);
  
blankpol = zeros(nc+3,2);
for jj = 1:nc
	igood = find(~isnan(u(:,jj)) & u(:,jj) < 1e30);
        if ~isempty(igood), pb = p(max(igood));
        else                pb = p(2);
        end
        blankpol(jj,:) = [x(jj)  pb];
end
blankpol((nc+1),:) =  [ x(nc) p(1) ];
blankpol((nc+2),:) =  [ x(1)  p(1) ];
blankpol((nc+3),:) =  blankpol(1,:);    % to close the polygon


% Round out the x limits.
xmin = min(x);
xmax = max(x);
imin = find(blankpol(:,1) == xmin);
imax = find(blankpol(:,1) == xmax);

rxmin = round(xmin/margin) * margin;
rxmax = round(xmax/margin) * margin; 

if rxmin < xmin, 
   blankpol(imin,1) = rxmin * ones(length(imin),1); 
end

if rxmax > xmax, 
   blankpol(imax,1) = rxmax * ones(length(imax),1); 
end
