From: Maxx Chatsko on
Hello all,
I have a gui that creates several plots in different windows. Obviously, the program will create the plot in the current figure. This is problematic if the user re-selects the main control figure right before the program creates the plot because it will appear in the background of the main control figure, not in the intended new figure (which is empty). I tried using set(gcf,'myfigure') and other commands...what command would I write before plot() to set the figure?
Thanks
Maxx
From: Maxx Chatsko on
I meant that I used figure() not set(), but I can't get the handle of the figure to put in the command figure()...any idears?
From: us on
"Maxx Chatsko" <chatskom(a)chemimage.com> wrote in message <i26t7s$ikf$1(a)fred.mathworks.com>...
> Hello all,
> I have a gui that creates several plots in different windows. Obviously, the program will create the plot in the current figure. This is problematic if the user re-selects the main control figure right before the program creates the plot because it will appear in the background of the main control figure, not in the intended new figure (which is empty). I tried using set(gcf,'myfigure') and other commands...what command would I write before plot() to set the figure?
> Thanks
> Maxx

one of the solutions

fh(1)=figure('name','fig1');
plot(1:10);
fh(2)=figure('name','fig2');
disp('press any key to cont...');
pause;
figure(fh(1));

us
From: Yuri Geshelin on
"Maxx Chatsko" <chatskom(a)chemimage.com> wrote in message <i26t7s$ikf$1(a)fred.mathworks.com>...
> Hello all,
> I have a gui that creates several plots in different windows. Obviously, the program will create the plot in the current figure. This is problematic if the user re-selects the main control figure right before the program creates the plot because it will appear in the background of the main control figure, not in the intended new figure (which is empty). I tried using set(gcf,'myfigure') and other commands...what command would I write before plot() to set the figure?
> Thanks
> Maxx

figure(N),

where N is the handle to the desired figure. If that figure exists, it will become current. Otherwise, it will be created.

Yuri
From: Walter Roberson on
Maxx Chatsko wrote:

> I have a gui that creates several plots in different windows.
> Obviously, the program will create the plot in the current figure. This
> is problematic if the user re-selects the main control figure right
> before the program creates the plot because it will appear in the
> background of the main control figure, not in the intended new figure
> (which is empty). I tried using set(gcf,'myfigure') and other
> commands...what command would I write before plot() to set the figure?

Don't do it that way. Instead, use explicit specification of the figure
number or axes or uipanel (or as appropriate) for every graphics
operation. The more common graphics operation often allow the parent to
be specified as the first parameter; the great majority of the other
graphic operations allow the parent to be specified by giving a 'Parent'
property in the calling list.

f = figure(123);
ax = axes('Parent', f);
plot(ax, rand(3,5));
line([0 0], [1 1], 'Parent', ax);