필터 지우기
필터 지우기

copyobj to copy .fig from Figure window to Axes inside GUI

조회 수: 6 (최근 30일)
Mechrod
Mechrod 2019년 8월 28일
댓글: Walter Roberson 2019년 8월 28일
Hello. This is my problem.
I have a GUI (one Figure) with several Tabs, and some of then have axes (mostly to plot a .jpg or a graph).
In one of this Tabs I have a button that has a callback which opens a new Window (Figure(2)), where it opens a .jpg and I draw some lines (imline) by hand, and then saves this Figure to a .fig file (using savefig). After that, i try to open the .fig file to one of the axes on the GUI.
In most of my attempts (using copyobj) i get the error "Axes cannot be a child of Axes". How can I solve this?
This is 'myhandles', which contains the handles of the GUI. The 'OWSO_main' is the Figure of the GUI, and 'W6_figure_tag' is the axes (inside a Tab) where i want to display the contents of the .fig file.
fig1.PNG
When i use Hfig = openfig('myfig.fig'), Hfig appears as a 1x1 Axes.
I have tried the approachs below, with no sucess.
I can provide more information if needed.
Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2019년 8월 28일
figure() objects can never be the child of an axes()
uipanel() can never be the child of an axes()
axes() can never be the child of an axes()
There is no possibility that you will be able to copyobj() the figure or the axes into an axes.
The closest you can get is to copy the children of the original axes into the new axes.
  댓글 수: 2
Mechrod
Mechrod 2019년 8월 28일
Thanks for the fast reply.
I think i understood what you said. Except:
"The closest you can get is to copy the children of the original axes into the new axes." . How can i do this? Do you have any suggestion?
Walter Roberson
Walter Roberson 2019년 8월 28일
axch = findall(OldAxes, 'depth', 1);
copyobj(axch, NewAxes)
It is tempting to instead use axch = children(OldAxes) but that will omit children whose handle visibility is not 'on'
Note that this will fail if you attempt to copy objects between the wrong kinds of axes. For example you cannot copy a polar() object to a regular axes. Also, you may need to take special steps if the old axes has datetime or duration axes .
Sometimes the easiest thing to do is not to copyobj, and to instead set the Parent property of OldAxes to the container of NewAxes (figure or uipanel) and then change the Units and Position properties to move it to the location inside the container that you want.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by