How to change figure properties for all figures in MATLAB?
조회 수: 56 (최근 30일)
이전 댓글 표시
Dear experts,
If in a MATLAB program there be plenty of figures, is it possible to specify a figure property (e.g. grid on) for all figures, instead of writing it after each figure command?
Regards,
Benjamin
댓글 수: 0
답변 (2개)
Steven Lord
2020년 12월 10일
You can set default property values for graphics objects that are created in the future. Changing the defaults will not change the property values for existing graphics objects (even if they used the default values for those properties when they were created.) For that you probably want to use findobj or findall to obtain the handles to those graphics objects (if you don't already have them) and change those property values. Run the commands in the example below one section at a time.
f1 = figure;
f2 = figure;
set(groot, 'DefaultFigureColor', 'r') % figures f1 and f2 do not change color
f3 = figure; % f3 is a different color than f1 and f2
allfigs = findall(groot, 'type', 'figure');
set(allfigs, 'Color', 'c'); % f1, f2, and f3 each become cyan
set([f2, f3], 'Color', 'k') % f2 and f3 become black, f1 remains cyan
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!