Legend not matching graph in specific code
1 view (last 30 days)
Show older comments
I used previous questions answers to get a template code working however, when I apply this to my real code, it doesn't change and outputs no errors so I am at a loss.
Here is my testing code which works correctly:

x=[0:1:20]
clf
hold on
L1=plot(x,2*x,'r')
L2=plot(x,3*x,'k')
L3=plot(x,4*x)
L4=plot(x,5*x,'k')
L5=plot(x,6*x,'b')
L6=plot(x,7*x,'k')
L7=plot(x,8*x)
L8=plot(x,9*x,'k')
L9=plot(x,10*x,'k')
L10=plot(x,11*x,'k')
L11=plot(x,12*x,'k')
legend([L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11],'2D velocities','6D velocities','10D velocities','Lower Nozzle','Uppper Nozzle','Centre Line','Upper Divergence Line','Lower Divergence Line','Upper Core','Lower Core','FontSize',6,'Location','best')
Here is my real code which doesn't work:
(I cannot provide the real data for it)

hold on
L1=plot(x_core,y_core1,'r');
L2=plot(x_core,y_core2,'r');
L3=plot(5*v_2+2*D,r_2);
L4=plot(5*v_6+6*D,r_6);
L5=plot(5*v_10+10*D,r_10);
L6=plot(x_nozzle,x_nozzle/4-15,'k');
L7=plot(x_nozzle,-x_nozzle/4+15,'k');
L8=plot(cl,cl*0);
L9=plot(div,div*topgrad+topint,'b');
L10=plot(div,div* botgrad+botint,'b');
L11=plot([0 0], ylim, 'k')
hold off
%applies axis labels
legend([L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11],'2D velocities','6D velocities','10D velocities','Lower Nozzle','Uppper Nozzle','Centre Line','Upper Divergence Line','Lower Divergence Line','Upper Core','Lower Core','Origin','FontSize',6,'Location','best')
I can't spot where the difference is.
5 Comments
Walter Roberson
on 14 Apr 2020
I would have thought that L8=plot(cl,cl*0); would be the Centre line, not L6=plot(x_nozzle,x_nozzle/4-15,'k'); ?
Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!