Using different line style, colour, and legend
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ke Yeun Yong
am 1 Okt. 2023
Kommentiert: Ke Yeun Yong
am 1 Okt. 2023
Hi, I have two lines in one graph, I am trying to set different line style, colour and legend of each line.
The following are the code I have so far.
Please give guidance. Very much appreciated.
X = Altitude;
Y = ROC_22K;
Z = ROC_26K;
plot(X([1:42]),Y([1:42]),X([1:42]),Z([1:42]),'Linestyle', '-', 'linewidth', 1.0);
xlabel('Altitude (m)','FontSize',14, 'fontweight', 'bold', 'color', '[0 0 1]')
ylabel('ROC (m/s)','FontSize',14, 'fontweight', 'bold', 'color', '[0 0 1]')
title('Rate of Climb Vs Altitude','FontSize',16, 'fontweight', 'bold', 'color', '#000000')
legend('Rate of Climb','Location','Bestoutside')
grid on
grid minor
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 1 Okt. 2023
Looks like you know how to use MATLAB. About all I might offer is to use the 'Color' option in plot to specify specific colors. Or you can look at colororder to set up a sequence of default colors to use if you don't use the color option.
If you want different linestyles, I'd plot them separately:
% Plot Y vs. X with one linestyle.
plot(X([1:42]),Y([1:42]), 'Color', 'r', 'Linestyle', '-.', 'linewidth', 1.0); % first linestyle
hold on; % Don't blow away prior plot.
% Plot Z vs. X with a different color and linestyle.
plot(X([1:42]),Z([1:42]), 'Color', 'b', 'Linestyle', '--', 'linewidth', 2.0); % Different linestyle
help colororder
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!