필터 지우기
필터 지우기

Invalid property: Returned figure handles not valid

조회 수: 1 (최근 30일)
Jamie
Jamie 2013년 10월 28일
답변: Jamie 2013년 10월 28일
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'

채택된 답변

Sean de Wolski
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

추가 답변 (2개)

Walter Roberson
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')

Jamie
Jamie 2013년 10월 28일
Thank you both kindly! I've been scratching my head for the past couple of days on that one. My 'test figures' obviously didnt include any of the aditional handles hence the irregularity (and ensuing frustration!).
Thank you both!

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by