필터 지우기
필터 지우기

Only plotting on the last of three axes?

조회 수: 1 (최근 30일)
Harry Smith
Harry Smith 2017년 11월 16일
댓글: Harry Smith 2017년 11월 16일
I have three axes on the same figure. Each axes has its own plot function. The first time the code runs it prints on the correct axes. On the second time the functions are called, all three plots are shown in the last axes in sequence Tried cla, cla reset, and many others Does this have an obvious solution which I am missing?

채택된 답변

Guillaume
Guillaume 2017년 11월 16일
Each axes has its own plot function. What does that mean?
If a figure has several axes, that means you used subplot to create the axis. You need to save the handle of these axis in order to replot in them:
figure;
hax(1) = subplot(1, 3, 1); %save handle of 1st axis
plot(sin(linspace(0, 2*pi, 200)));
hax(2) = subplot(1, 3, 2); %save handle of 2nd axis
plot(sqrt(linspace(0, 5, 200)));
hax(3) = subplot(1, 3, 3); %save handle of 3rd axis
plot(log(linspace(0, 5 , 200)));
To replot in all axis
plot(hax(1), tan(linspace(0, 2*pi, 200))); %plot in first axis
plot(hax(2), linspace(0, 5, 200).^2); %plot in second axis
plot(hax(3), exp(linspace(0, 5, 200))); %plot in 3rd axis
Alternatively, if you don't want to store the axis, you can reissue the subplot command:
subplot(1, 1, 1); %replot in first axis
plot(cos(linspace(0, 2*pi, 200)));
subplot(1, 1, 2); %replot in second axis
plot(linspace(0, 5, 200));
subplot(1, 1, 2); %replot in 3rd axis
  댓글 수: 1
Harry Smith
Harry Smith 2017년 11월 16일
Thanks Not use subplot, only plot
I will read and learn, many thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by