Requesting legend output changes legend behavior
1 view (last 30 days)
Show older comments
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
on 28 Jan 2016
Very strange!
I can tell you that I do not see that behavior in R2015b on OS X Yosemite.
Accepted Answer
More 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!