How to use/skip multiple strings in a legend

2 views (last 30 days)
Dylan Stelzer
Dylan Stelzer on 21 Nov 2013
Answered: Simon on 21 Nov 2013
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

Answers (1)

Simon
Simon on 21 Nov 2013
Hi!
Did you read this page? Controlling Legends

Products

Community Treasure Hunt

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

Start Hunting!