How to change figure properties for all figures in MATLAB?
55 次查看(过去 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!