
function rzap(ax)

% use to zap bins that fall within the rectangular region
% defined by [pmin pmax bmin bmax] = inside1(ax);

%editglob
global EDIT_MODE CURRX DISP YAXIS BADBIN BADBIN_BAK
global LISTED LASTCOMM LASTPLOT

if ~EDIT_MODE
  error('You are not in edit mode.  Set EDIT_MODE = 1 to enable.')
end

if nargin < 1
  if isempty(CURRX)
    error('You must plot a variable first before running this without args')
  end
   if v4,
        disp('Click on upper left and bottom right corners to select region')
        [x y] = ginput(2);
        ax = [x(1) x(2) y(2) y(1)];
   else
      ax = mousebox;
   end

end

[pmin pmax bmin bmax] = inside1(CURRX+DISP, YAXIS, ax);
if ~isempty(pmax)
  BADBIN_BAK = BADBIN;
  LISTED = 0;
  iflagged = find(BADBIN ~= 0);
  BADBIN(bmin:bmax,pmin:pmax) = BADBIN(bmin:bmax,pmin:pmax) - 2; % -2 = user-added
  BADBIN(iflagged) = BADBIN_BAK(iflagged);  % reset to orig. value if previously flagged
  eval(LASTPLOT)
  LISTED = 0;   % bad bins flagged but not yet listed
  LASTCOMM = 'badbin';
end
