How to copy hggroup object from one figure to the other
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to copy an hggroup object (such as text-box created in PlotEditor, ot text-arrow) from one figure to the other. It is very easy to do it just by {Ctrl+C,Ctrl+V}, but how can I do it in a script? Copyobj does not work appropriately (when I use it hggroup objects become uneditable and behave strangely in a new figure). Anybody knows the solution?
P.S. I have posted similar question previously (although probably not formulated well), but no solution was found and it seems that it was forgotten, so I repost one more time and with a better formulation of the problem.
Thank you in advance,
Dima
[Moved from comment section, Jan]
It can be illustrated as following:
1. Create two figures: h1=figure; h2=figure;
2.Create a text-box object in the first figure h1 using PlotEditor (Insert->TextBox), write something in it, select it and get its handle by hgh=gco;
3. Select the next figure h2 and find its basic invisible axes as set(0,'ShowHiddenHandles','on'); iax=findobj(gcf,'type','axes','HandleVisibility','off');
4. Then copy TextBox hggroup object hgh to that axes iax: copyobj(hgh,iax);
Then the copied textbox in the figure 2 can't be edited anymore (nor text in it changed, nor its size), as well as text become shifted in respect to the frame when you change figure size, which does not happen with the original one.
7 个评论
回答(2 个)
Jan
2012-12-24
You cannot expect, that objects created by the interactive PlotEditor behave equally after they have been posted to another figure. Beside the visible objects, callbacks are created and attached to the actions of the figure. And the missing of these callbacks reproduce the observed behavior.
I suggest to use another method to insert the objects in the new figure.
Thomas
2015-11-19
编辑:Walter Roberson
2015-11-19
Actually, this is possible:
f1=figure;
textbox=annotation('textbox','String','Hello World');
f2=figure;
newbox=annotation(f2,'textbox')
%may want to add:'linestyle','none' and/or 'position',textbox.Position
copyobj(textbox,newbox.Parent);
%this copies it into the annotationpane for newbox
Regards
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!