Requesting legend output changes legend behavior

1 view (last 30 days)
In Matlab R2015b (64bit on Windows 7), the following two bits of code cause different legends to be displayed:
figure;
scatter(1:100,sin((1:100)/50*pi));
hold on;
scatter(1:100,cos((1:100)/50*pi));
legend('sin','cos');
figure;
scatter(1:100,sin((1:100)/50*pi));
hold on;
scatter(1:100,cos((1:100)/50*pi));
[eg,i,p,s] = legend('sin','cos');
The first line displays a legend with two entries having the same color (the "last" one) and the second line displays a legend having two different colors. Can somebody explain this? Surely, requesting output parameters should not have an effect on the legend itself, or should it?
  2 Comments
the cyclist
the cyclist on 28 Jan 2016
Very strange!
I can tell you that I do not see that behavior in R2015b on OS X Yosemite.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Jan 2016
Known bug that affects scatter; there is a fix
  1 Comment
N. Otime
N. Otime on 28 Jan 2016
Indeed my second line corresponds to work-around number 3 in the linked fix.
Thanks for the quick reply!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!