SUBPLOT 関数で表示した軸にグラフを重ね描きする方法はありますか?
13 views (last 30 days)
Show older comments
下記のようにグラフを重ねて描画したいのですが、上書きされてしまい意図した結果になりません。重ね描きする方法を教えてください。
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
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!