As of Matlab 2018a, legend() now supports columns, so function will no longer be maintained: https://www.mathworks.com/help/matlab/ref/legend.html#d117e809522
Updated 9/8/16: Added new legend positions (e.g. northeastoutside) and better positioning.
numlines = 5;
r = rand(10,numlines);
columnlegend(2, cellstr(num2str([1:numlines]')), 'location', 'northeastoutside');
PRINTING: If you want to print the figure, you'll have to use a command line printer (e.g. export_fig) as the File->Print option embedded in the figure resets the figure properties including the legend
Simon Henin (2022). simonhenin/columnlegend (https://github.com/simonhenin/columnlegend), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!