How to stop subsequent plots outputting to the current pane?

조회 수: 182 (최근 30일)
Michael O'Brien
Michael O'Brien 2021년 3월 31일
댓글: Michael O'Brien 2021년 4월 1일
On this page it states:
Description
subplot divides the current figure into rectangular panes that are numbered rowwise. Each pane contains an axes object. Subsequent plots are output to the current pane.
How do I get it to stop doing that?
If I've called subplot previously then I call plot in the command window to quickly check some data the new plot updates the last plotted subplot.
Thank you for your help in advance.

채택된 답변

Mohammad Sami
Mohammad Sami 2021년 3월 31일
To force MATLAB to create new figure, you need to call figure function before calling the plot.
  댓글 수: 3
Mohammad Sami
Mohammad Sami 2021년 4월 1일
Unfortunately there is no such option. The only way you can ensure the plot goes where you want it to go, you should pass the axes handle as the first argument of your plot function. This would ensure the plotting uses the correct axes. You can also alternatively call axes(existing), subplot(existing), figure(existing) to make them the current axes / current figure that will be used to plot.
% example
f = figure;
a = axes(f);
plot(a,1:10,1:10);
f2 = figure;
a1 = subplot(2,1,1);
plot(a1,1:10,1:10);
a2 = subplot(2,1,2)
plot(a2,1:10,1:10);
hold(a1,'on');
plot(a1,10:-1:1,1:10);
subplot(a2);
plot(10:-1:1,1:10);
figure(f);
hold(gca,'on');
plot(10:-1:1,1:10);
Michael O'Brien
Michael O'Brien 2021년 4월 1일
ok, so if I wanted to do a quick plot to check some data without it updating the last subplot I would type
figure; plot(x,y);
in the command window?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by