Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Q] How to open fig file in an existing figure window?

270 views
Skip to first unread message

Kevin Hung

unread,
Mar 18, 2002, 1:04:37 PM3/18/02
to
I know that I can use the function "open" to load a *.fig file into a
new figure window. However I would like to load the figure into
existing figure window. Can this be done?

Thanks.

Paul Casey

unread,
Mar 18, 2002, 4:06:48 PM3/18/02
to
Not directly -- but you could open the fig file (have it already set
to invisible if you want) find all the children (or part thereof) of
the fig (see allchild.m & findall.m) and set their parent properties
to the figure you want to transfer them to. I don't quite understand
the reasoning behind this.
Here's a simple example
fig = open('myfig') % a figure you have already saved
newfigH = findall(newfig) %get the handles of the figure to copy to
delete(newfigH(2:end)) %delete all but the figure itself
children = allchild(fig) %move children form one fig to the other
delete(fig) %delete the now empty figure


A little more info on what you are actually trying to do would be
helpful. I am interested in this sort of thing too as I want to
simulate the appearance of having more than one window in a figure so
that the user can appear to tab through different windows. Matlab
does not have a super container for figures so this is not possible.
Copying of hidden figure children seesm to be a way of appearint ot
have this functionality.


Paul

Jordan Rosenthal

unread,
Mar 19, 2002, 8:12:25 AM3/19/02
to
Hi,

The basic steps are

1) Open the figure. Using hgload(...,'visible','off') to do this is nice
because it keeps the figure invisible.
2) Use COPYOBJ with some combination of FINDOBJ, FINDALL, or ALLCHILD to
copy the old figure's objects to the new figure. When using FINDOBJ or
FINDALL you may need to remove the figure object from the returned
vector. You may need to remove other things as well, like Matlab's
built-in menus, etc. Functions like SETDIFF can be useful for this.
3) One can, if necessary, use REMAPFIG to reposition the objects within
the new figure.

Hope that helped,

Jordan

Kevin Hung

unread,
Mar 19, 2002, 11:31:53 AM3/19/02
to
"Paul Casey" <p.c...@dta.mil.nz> wrote in message news:<eeab...@WebX.raydaftYaTP>...

> Kevin Hung wrote:
> >
> >
> A little more info on what you are actually trying to do would be
> helpful. I am interested in this sort of thing too as I want to
> simulate the appearance of having more than one window in a figure so
> that the user can appear to tab through different windows. Matlab
> does not have a super container for figures so this is not possible.
> Copying of hidden figure children seesm to be a way of appearint ot
> have this functionality.
>
>
> Paul


I have a few dozen figure files saved on hard-disk and I would like to
run a loop to display each figure file. Instead of Matlab popping all
different figure window, I would like to load each file sequentially
into one figure window.

Thanks for your help. I will try it out.

0 new messages