savehold: Run the 'hold on' command and save its state for possible restoration

버전 1.0.0.0 (1.73 KB) 작성자: Petr Posik
A small utility encapsulating the call to 'ishold', 'hold on' and a restortion of the hold state.
다운로드 수: 492
업데이트 날짜: 2010/2/3

라이선스 보기

Assume we have axes inside a figure with some plots already there. We want to add some plots and then restore the state of hold (if it was 'on' before, we want it to stay 'on' after; if it was 'off' before, we want to set it back to 'off').

It can be done by the following commands:

>> % Commands plotting something and setting 'hold on' or 'hold off'
>> % Now, we want to add some plots
>> washold = ishold; % Get the 'state of hold' for the current axes
>> hold on; % Set the 'hold' property to 'on'
>> plot(something);
>> plot(something different);
>> if ~washold, hold off; end % Reset the state of hold if needed

With SAVEHOLD, the above code can be simplified a bit to:

>> % Commands plotting something and setting 'hold on' or 'hold off'
>> % Now, we want to add some plots
>> h = savehold();
>> plot(something);
>> plot(something different);
>> h.restore();

인용 양식

Petr Posik (2024). savehold: Run the 'hold on' command and save its state for possible restoration (https://www.mathworks.com/matlabcentral/fileexchange/26574-savehold-run-the-hold-on-command-and-save-its-state-for-possible-restoration), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R14
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
도움

줌: Take & Restore hold

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0