How to use/skip multiple strings in a legend

2 ビュー (過去 30 日間)
Dylan Stelzer
Dylan Stelzer 2013 年 11 月 21 日
回答済み: Simon 2013 年 11 月 21 日
Hi all, I had a quick question I was hoping someone here could help me with. I am trying to plot a series of plots, lines, and points on one figure and am now at the legend making part. I am tring to keep my legend short and simple by skipping some (repetitive) strings but keep getting an error. Even after looking through many solutions here. Any help would be so much appreciated! Thank you in advance! Dylan
Ex: %Plotting the data
figure(1)
%Plot Power Required vs Velocity For Each Altitude
a=plot(Vknots,Prhp_SL,'k-');
b=plot(Vknots,Prhp_1H,'r--');
c=plot(Vknots,Prhp_2H,'b-.');
%Plot Data Points Asked for on Final Project Sheet
hold all
d=line([Vstall_SL Vstall_SL],[0 160],'Color','k','LineStyle',':');
e=line([Vstall_1H Vstall_1H],[0 160],'Color','r','LineStyle',':');
f=line([Vstall_2H Vstall_2H],[0 160],'Color','b','LineStyle',':');
g=plot([V_Prmin_SL V_Prmin_SL],[Prmin_SL Prmin_SL],'ko');
h=plot([V_Prmin_1H V_Prmin_1H],[Prmin_1H Prmin_1H],'ko');
i=plot([V_Prmin_2H V_Prmin_2H],[Prmin_2H Prmin_2H],'ko');
j=plot([V_maxLD_SL V_maxLD_SL],[TRmin_SL TRmin_SL],'kd');
k=plot([V_maxLD_1H V_maxLD_1H],[TRmin_1H TRmin_1H],'kd');
l=plot([V_maxLD_2H V_maxLD_2H],[TRmin_2H TRmin_2H],'kd');
%Add good graphing etiquittes
% Title of plot
title('Power Required vs Velocity for Different Altitudes');
%Set the Axis
axis([40 150 25 160]);
%Plot labels
xlabel('Velocity (knots)');
ylabel('Power (hp)');
%Plot legend
legend([a b c d g],'Sea Level','5,000 ft','10,000 ft','Stall Speed','P_R_m_i_n','Location','NorthEastOutside');
%Finished

回答 (1 件)

Simon
Simon 2013 年 11 月 21 日
Hi!
Did you read this page? Controlling Legends

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by