Legend always wrong in MATLAB R2016b
Show older comments
If I try to add a legend within my plots, the legend looks always strange. I tried the example code from the legend documentation. I tried adding only one or more entries. Also the work-around with 'DisplayName' gives the same strange legend-output. If I use the following simple code:
clear
x = linspace(1,5,100);
y1 = x.^2;
y2 = 3*x;
figure(1)
clf
plot(x,y1,x,y2);
legend('y1','y2')
I got this plot:

What goes wrong with my Matlab and how can I fix it? It is no sustainable solution to set all the individual parameters for every single legend entry. I'm thankful for every support.
1 Comment
KALYAN ACHARJYA
on 4 Oct 2018
I don't have 2016b, in 15b its works perfectly.
x=linspace(1,5,100);
y1=x.^2;
y2=3*x;
figure(1)
clf
plot(x,y1,x,y2);
legend('y1','y2','location','northwest');

Answers (1)
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!