フィルターのクリア

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 Center および File ExchangeSpecifying 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