Invalid property: Returned figure handles not valid
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sean de Wolski
2013-10-28
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 个评论
更多回答(2 个)
Walter Roberson
2013-10-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!