Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get handle of the legend of a plot generated through plotyy when importing a fig file?

Tags:

matlab

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?

like image 728
InquilineKea Avatar asked Dec 18 '25 14:12

InquilineKea


1 Answers

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.

like image 111
Robert Seifert Avatar answered Dec 21 '25 04:12

Robert Seifert