Legend always wrong in MATLAB R2016b

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

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');

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 4 Oct 2018

1 Comment

Adding a 'Location' like proposed is not helping. There is sill "Warning: Error updating Legend. not enough input arguments" with the same strange legend.

Sign in to comment.

Products

Release

R2016b

Asked:

on 4 Oct 2018

Commented:

on 4 Oct 2018

Community Treasure Hunt

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

Start Hunting!