Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

why i couldn't creat hgtransform graphics object before the objects belong to it

조회 수: 1 (최근 30일)
213
213 2014년 6월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
this code is ok
>> ph=fill([0 -0.05 0.1 -0.05],[0 0.05 0 -0.05],'r');
>> hgh=hgtransform;
>> set(ph,'parent',hgh)
but these are wrong:
>> hgh=hgtransform;
>> ph=fill([0 -0.05 0.1 -0.05],[0 0.05 0 -0.05],'r');
>> set(ph,'parent',hgh)
Error using set
Invalid object handle
>> hgh=hgtransform;
>> fill([0 -0.05 0.1 -0.05],[0 0.05 0 -0.05],'r','parent',hgh)
Error using fill
Not enough input arguments.
i coudn't understand why it can't work
  댓글 수: 2
213
213 2014년 6월 20일
Note   Many plotting functions clear the axes (i.e., remove axes children) before drawing the graph. Clearing the axes also deletes any hgtransform objects in the axes.
Mike Garrity
Mike Garrity 2014년 6월 24일
Yes, that's exactly why the one with the set failed.
You can see the hgtransform get deleted by the clear of the axes if you do the following:
hgh=hgtransform('DeleteFcn','disp bye');
ph=fill([0 -0.05 0.1 -0.05],[0 0.05 0 -0.05],'r');
ishghandle(hgh)
You'll see the hgtransform object print bye from within the fill command. Then when we get to the ishghandle command, hgh is no longer a valid handle.
Your last example is actually a bug. The fill command is deleting the hgtransform object as you noted, but it shouldn't have because you passed it in as the parent.
You can work around either of these by using "hold on".

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by