copyobj to copy .fig from Figure window to Axes inside GUI
3 次查看(过去 30 天)
显示 更早的评论
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.
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.
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!