Invalid property: Returned figure handles not valid
3 views (last 30 days)
Show older comments
When using the command
Hndl = get(gcf,'Children')
to obtain the axis handles of a 3x1 subplot I am recieve more handles than anticipated
i.e.
Hndl =
399.0060
398.0060
397.0060
396.0060
395.0060
381.0033
363.0033
356.0038
When attempting to use one/all of these handles i.e.
set(Hndl,'NextPlot','add')
I recieve the error
"Error using set
Invalid property found.
Object Name : uicontextmenu
Property Name : 'NextPlot'."
Any help would be greatly appreciated!! Plotting simple examples and overlaying additional plots on the subplot axis works without any problem. In implementation in my programme the figure handles are always 'invalid'
0 Comments
Accepted Answer
Sean de Wolski
on 28 Oct 2013
get(gcf,'children')
returns the handles to all of the unhidden children of the figure including uimenus and uicontextmenus etc.
Instead, use findobj and specify the type to be 'axes' so it only gives you axes handles:
hAx = findall(gcf,'type','axes')
Even better would just be to store the handles when you create the subplot
for ii = 3:-1:1
hAx(ii) = subplot(3,1,ii);
plot(rand(1,10));
end
0 Comments
More Answers (2)
Walter Roberson
on 28 Oct 2013
You can
get(Hndl, 'Type')
to see what they are. You should expect multiple axes if you have a legend. You should expect that figure might have menu bars.
If you only want axes, then use
Hndl = findobj(cf, 'type', 'axes')
0 Comments
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!