I'd like to get the handle of the legend of the figure here so that I can copy the figure's legend entries when replotting the legend on a subplot.
If I try to find the axes by running findobj(ax1,'Type','axes','Tag','legend') though, it just returns an Empty matrix: 0-by-1. Is there another way to get the legend?
Your mistake was, that you used the axes handle instead of the figure handle:
leg = findobj(figureHandle,'Type','axes','Tag','legend')
or simply:
leg = findobj(gcf,'Tag','legend')
will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With