This function creates a legend in which the entries are arranged in a grid or table.
If you are plotting a large number of results, a regular legend can be overwhelming. Many times, however, the results can be logically arranged in a grid or table. This function creates a grid legend, which can take up less space than a regular legend and can be easier for the reader to understand. This function accepts many of the same name-value pair inputs as the built-in legend function to give the user control over the location and appearance of the grid legend.
An example function is also included to demonstrate some of the features of grid legend.
Shane L (2020). GridLegend (https://www.mathworks.com/matlabcentral/fileexchange/66464-gridlegend), MATLAB Central File Exchange. Retrieved .
Great improvement on built-in legend() function, highly recommended.
I've come across a couple of minor issues, which I'm still trying to figure out and resolve--
- sometimes there is a lot of additional whitespace at the right side of each output row in the rendered legend
- with multiple subplots, even if one passes in a leading axis handle as argument #1, each successive call to gridlegend() deletes the prior gridlegend rendered in a different subplot.
Very useful function which is simple to use.
Note: This function seems to not support patch.
Works well, I'm very glad I found this.
This was extremely helpful for my figure plots!!
Added a variable to independently set the heights of the column headers row and the rest of the rows in the grid. This way, if there are subscripts or superscripts in the column headers, the remainder of the rows are not too widely spaced.