classdef holdon < handle

    properties
     hAx;
     hState;
    end
   
    methods
        
        function obj=holdon(hAx)
        %obj=holdon(hAx) 
        %
        %  hAx: handle to axis to be held (default=GCA).
 
             hAx0=gca;

             if ~nargin
                 hAx=hAx0;
             end

             hState=hAx.NextPlot;
             hAx.NextPlot='add';
            
             obj.hAx=hAx;
             obj.hState=hState;
            
        end
        
        function restore(obj)
            hAx=obj.hAx;
            hAx.NextPlot=obj.hState;
        end
        
        function hold(obj)
            
            obj.hState=obj.hAx.NextPlot;
            obj.hAx.NextPlot='add';
            
        end
        

    end
   
end



