determine axes handle to which a legend belongs
6 views (last 30 days)
pre 2014b I was able to use the following to get the axes handle to which a legend belongs
from 2014b on this throws an error, because the UserData is empty.
Is there a way to determine to which axes in an existing figure a legend belongs? As an example:
y = rand(3,5);
s1 = subplot(2,2,1);
l = legend('toggle');
s2 = subplot(2,2,2);
In the example I either want to get l from s1 or s1 from l. s2 is there to make in non-trivial.
Walter Roberson on 4 Apr 2016
I recently noticed that legend and colorbar in R2014a and earlier have a hidden property named Axis . I suspect the property might still be there in R2015a onward; you could try that.
If that does not work, please experiment with http://www.mathworks.com/matlabcentral/fileexchange/32934-getundoc-get-undocumented-object-properties