SUBPLOT 関数で表示した軸にグ​ラフを重ね描きする方​法はありますか?

13 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 14 Dec 2009
下記のようにグラフを重ねて描画したいのですが、上書きされてしまい意図した結果になりません。重ね描きする方法を教えてください。
ax1 = subplot(2,1,1);
plot(ax1,rand(1,10))
ax2 = subplot(2,1,2);
plot(ax2,rand(1,10),'r')
hold on
plot(ax1,rand(1,10),'g')
hold off

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Dec 2009
デフォルトの設定では、SUBPLOT関数は重ね描きする際に、一度軸をクリアしその上から新しいグラフをプロットします。そこで、軸の'NextPlot'プロパティを'add'に設定することで、重ね描きを実現することができます。
ax1 = subplot(2,1,1);
plot(ax1,rand(1,10))
ax2 = subplot(2,1,2);
plot(ax2,rand(1,10),'r')
hold on
set(ax1,'NextPlot','add');
plot(ax1,rand(1,10),'g')
hold off

More Answers (0)

Community Treasure Hunt

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

Start Hunting!