function Cleanup = holdOn(Axes)
% Turn hold on and return an oncleanup object to turn hold off.

%   Copyright 2016-2022 The MathWorks, Inc.

hold(Axes, 'on');
Cleanup = onCleanup(@()holdOff(Axes));
    function holdOff(A)
        if isvalid(A)
            hold(A, 'off');
        end
    end
end