MATLAB: How to tell the difference between the legend and the plot axes from the results of a findobj(gc​f,’type’,’​axes’) command in MATLAB 7.5 ( R2007b )

MATLAB

When I query the figure for the axes , I get two two handles, both of which have 'Type' 'Axes'.
line
legend('myLegend');
a = findobj(gcf,'type','axes');

Best Answer

The 'Tag' Property can be used to differentiate between an axes and a legend.
line;
legend('myLegend');
a = findobj(gcf,'type','axes');
get(a,'tag');
This above example returns
ans =
'legend'
''