Why does calling the legend function with multiple outputs throw a warning in MATLAB R2024b?
Show older comments
When I use the "legend" function in MATLAB R2024b, I encounter the below warning:
Warning: Calling legend with multiple outputs will not be supported in a future release
I see this after running the following script:
figure; hold on;
x = linspace(0, 2*pi, 200);
p(1) = plot(x, sin(x), 'LineWidth', 1);
p(2) = plot(x, cos(x), 'LineWidth', 1);
p(3) = plot(x, sin(2*x), 'LineWidth', 1);
hold off
[~, legObjs] = legend(p, {'Sine', 'Cosine', 'Sin 2x'}, 'Location', 'best');
Why does this warning occur and how should I use the "legend" function to avoid this issue while maintaining current functionality?
Accepted Answer
More Answers (0)
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!