How to change figure properties for all figures in MATLAB?
55 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Rik
el 10 de Dic. de 2020
set(groot,'defaultFigureCreateFcn',@(fig,~)SomeFunction(fig))
0 comentarios
Steven Lord
el 10 de Dic. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!