MATLAB Answers

How can I modify appearence of multiple plots?

3 views (last 30 days)
Jonathan Bijman
Jonathan Bijman on 15 Jun 2019
Commented: dpb on 15 Jun 2019
Hi everyone
I have these commands for plotting 6 variables with its deviations standards respective.
x = linspace(0, 54, numel(T_A8_C));
X = [x;x;x;x;x;x].';
Y = [T_A8_C(:) T_C5_C(:) T_E1_C(:) T_A8_D(:) T_C5_D(:) T_E1_D(:)];
err=[T_desvA8_C(:) T_desvC5_C(:) T_desvE1_C(:) T_desvA8_D(:) T_desvC5_D(:) T_desvE1_D(:)];
title('Cell Temperature Plot')
xlabel('Time (Days)')
ylabel('Cell Temperature (°C)')
legend('A8 Clean','C5 Clean','E1 Clean','A8 Dirty','C5 Dirty','E1 Dirty');
And I want:
all variables with A8 red color, all variables with C5 blue color, all variables with E1 black color.
all variables with C with a line continuous (a little thicker than default) and all variables with D in segments (either dot-dot or dash-dot)
How can I do that with too many variables?
Thanks for your help!


Sign in to comment.

Accepted Answer

dpb on 15 Jun 2019
Save the errorbar object returned handles and set properties as desired.


Show 1 older comment
dpb on 15 Jun 2019
hEB=errorbar(X,Y,err); % save returned errorbar object handles
hEB(1).Color=... % set given line color
Since the dot notation is only able to address a single handle at a time, if you were to define arrays of properties like colors by line for each grouping, then you can cut down the actual amount of code significantly by using the set command to set the entire array of handles at one time by passing a cell array of the proper size. There are examples of such use in the documentation for set. This would draw all the lines as default and then set the proroperties afterwards. If you cared about the appearance in the intermediate stages all that much, you could add each individually with hold on and set each line style when plotted. The first is more efficient...
dpb on 15 Jun 2019
Glad to pays to read and search the documentation for "how to" topics...

Sign in to comment.

More Answers (0)