You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
The introduction of HG2 has removed an (undocumented) feature of legends - the ability to easily add titles to them.
This function is to replace/replicate that behaviour.
The function works on both HG1 and HG2.
hTitle = legendTitle ( hLegend, 'your title string' );
The function accepts arg pairs to format/customise the legend.
Function has listeners for the legend changing "Location", "Position" and being Deleted. A listener is also added to the parent figure when it changes size.
This submission is part of the matpigui toolbox (available from www.matpi.com)
Cite As
Robert Cumming (2026). Add a title to a legend (https://uk.mathworks.com/matlabcentral/fileexchange/48331-add-a-title-to-a-legend), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: LEGENDTITLE
General Information
- Version 1.2.0.0 (1.8 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
