Combined Legend for multiple axes
A simple demo to show how you can obtain the children object handles in plot determine their type and do something with it.
If you have multiple axes in one figure but wish to have one legend for all the lines in axes. The conventional way would be to provide all the handles of the lines in your axes to the built in function 'legend'. But instead use this method and just pass the figure handle.
This script will search for all the axes and the lines within it and provides the legend.
Also you can give an array of axes handles.
Since it uses the built in legend function all the options are supported.
Cite As
Shreyes (2026). Combined Legend for multiple axes (https://www.mathworks.com/matlabcentral/fileexchange/35662-combined-legend-for-multiple-axes), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
