Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: copyobj from existing figure into GUI axes
Date: Sat, 29 Nov 2008 22:24:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <ggsfe1$e3d$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227997441 14445 172.30.248.35 (29 Nov 2008 22:24:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 29 Nov 2008 22:24:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:503837


Hi, I am trying to display a previously created figure in a GUI axes. I think I need to use the copyobj function and have written the below lines of code, but I can't get it to work:

[FileName,PathName]=uigetfile('.fig','Select a figure'); % user selects the figure
figure_handle = openfig(strcat(PathName,FileName)); % figure is opened
h=handles.axes1; % handle to axes in GUI
copyobj(allchild(figure_handle),h);  % original figure is copied to new figure

It returns this error: 
??? Error using ==> copyobj
Object uicontextmenu[1] can not be a child of parent axes[1]
Error in ==> figure_viewer>pushbutton1_Callback at 100
copyobj(allchild(figure_handle),h);

I can't work out what I need to do to resolve this, but I have found that if I replace 'h=handles.axes1' with 'h=figure' it works and correctly copies the original figure to a new figure, but I want it to copy it to the axes within the GUI.

Any ideas? Thanks.