This short function will generate a legend based on 'Tag' information given by plot. A legend title is also possible.
figure; hold on; x = 1:10; plot(x,x,'Tag','Positive'); plot(x,-x,'Tag','Negative'); labelplot('eo','v','Slope');
The above example is equivalent to
legend('Positive','Negative')
and adding a text box 'Slope' above it.
Cite As
Will Robertson (2024). labelplot (https://www.mathworks.com/matlabcentral/fileexchange/11234-labelplot), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2006a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
Find more on Legend in Help Center and MATLAB Answers
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.