I have multiple figures open, and I want to update them independently during runtime. The following toy example should clarify my intention:
clf;
figure('name', 'a and b'); % a and b should be plotted to this window
hold on;
ylim([-100, 100]);
figure('name', 'c'); % only c should be plotted to this window
a = 0;
b = [];
for i = 1:100
a = a + 1;
b = [b, -i];
c = b;
xlim([0, i]);
plot(i, a, 'o');
plot(i, b(i), '.r');
drawnow;
end
The problem here is that when I open the second figure
, I cannot tell the plot
functions to plot to the first one instead of the second (and only c
should be plotted to the second).
plot( X , Y ) creates a 2-D line plot of the data in Y versus the corresponding values in X . To plot a set of coordinates connected by line segments, specify X and Y as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix.
Go to "Edit" in the figure window. Go to "Figure Properties" At the bottom, you can type the name you want in "Figure Name" field. You can uncheck "Show Figure Number".
Plots a drawing to a plotter, printer, or file in the command line.
You can use something like
figure(1)
plot(x,y) % this will go on figure 1
figure(2)
plot(z,w) % this will go on another figure
The command will also set the figure visible and on top of everything.
You can switch back and forth between the figures as necessary by issuing the same figure
command. Alternatively, you can use the handle to the figure as well:
h=figure(...)
and then issue figure(h)
instead of using numeric indices. With this syntax, you can also prevent the figure from popping up on top by using
set(0,'CurrentFigure',h)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With