legend_reverse
Version 3.0 (1.25 KB) by
Moses
Create legend in reverse order. Uses the same name-pair arguments as the default legend() function.
Create legend in reverse order. Uses the same name-pair arguments as the default legend() function.
-Line plots
-Stacked bar graphs
Example 1:
x = 1:3;
y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];
plot(x, y, 'LineWidth', 2)
legend_reverse('blue', 'red', 'orange', 'purple', 'Location', 'northwest');
Example 2:
y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];
bar(y,'stacked');
legend_reverse('blue', 'red', 'orange', 'Location', 'northwest');
Cite As
Moses (2026). legend_reverse (https://nl.mathworks.com/matlabcentral/fileexchange/79577-legend_reverse), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2020a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by: Flip bar legend
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
