# How to change properties of several plots simultaneously?

79 views (last 30 days)
Zeynab Mousavikhamene on 5 Aug 2020
Commented: Walter Roberson on 6 Aug 2020
I want to set properties of several plots all at once instead of setting them individually.
figure(1)
plot(x,y,'--gs','LineWidth',...'MarkerSize',...,'MarkerEdgeColor',...,'MarkerFaceColor',...)
figure(2)
plot(xx,yy,'--gs','LineWidth',...'MarkerSize',...,'MarkerEdgeColor',...,'MarkerFaceColor',...)
figure(3)
plot(xxx,yyy,'--gs','LineWidth',...'MarkerSize',...,'MarkerEdgeColor',...,'MarkerFaceColor',...)
,...
Assuming that properties are the same (linewidth, markersize,...) I want to set them once and not repeat it for each plot.
dpb on 6 Aug 2020
Edited: dpb on 6 Aug 2020
Save the line handles when you plot and use set() See the doc for syntax and examples.
(BTW, the properties don't even have to be the same value...)

Steven Lord on 6 Aug 2020
x = 0:360;
y1 = sind(x);
y2 = cosd(x);
figure
h1 = plot(x, y1);
figure
h2 = plot(x, y2);
set([h1, h2], 'Marker', '^', 'LineStyle', '--', 'MarkerIndices', 1:10:numel(x))
Or write a function that accepts x and y data, opens a figure and calls plot with the appropriate properties, then call that function repeatedly with each of your data sets.
Walter Roberson on 6 Aug 2020
MATLAB's idea of what the "current" figure or axes is, can change without warning. Please read https://www.mathworks.com/matlabcentral/answers/?term=tag%3Aalways-parent