MATLAB Answers

How to change properties of several plots simultaneously?

1 view (last 30 days)
Zeynab Mousavikhamene
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.
Assuming that properties are the same (linewidth, markersize,...) I want to set them once and not repeat it for each plot.
Thanks in advance

  1 Comment

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...)

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 6 Aug 2020
x = 0:360;
y1 = sind(x);
y2 = cosd(x);
h1 = plot(x, y1);
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.


Show 4 older comments
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 6 Aug 2020
@Walter Roberson :
No. What is App designer? I write the commands on the matlab script.
Walter Roberson
Walter Roberson on 6 Aug 2020
App Designer is the replacement for GUIDE; it is a UI design tool. It creates a class to hold all of the data. It also uses the new uifigure() and uiaxes() and related objects.

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by