multiple plots on a subplot
91 ビュー (過去 30 日間)
古いコメントを表示
I just want something generic so I can have two subplots and two graphs on each subplot. I know how to do the two subplots but having two different graphs on each subplot is the problem. Thanks
0 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 2 月 19 日
編集済み: Azzi Abdelmalek
2013 年 2 月 19 日
Use hold on
t=0:0.1:10;
y1=sin(t)
y2=cos(t)
subplot(2,1,1)
plot(t,y1)
hold on
plot(t,y2,'r')
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2013 年 2 月 19 日
Should the two graphs be in the same visual axes? If so then "hold on" or "plotyy".
If not, if you are wanting to subdivide a subplot into further subplots, then you can use subplot for that with a bit of creativity.
Example: suppose you are subplotting 3 (down) x 5 (across), and you want the last in the middle row to be subdivided. That is 15 subplots, which MATLAB numbers row first -- so
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
Thus normally that subplot would be reached by subplot(3, 5, 10) -- a 3 x 5 matrix and pick element #10 out of that.
Now to subdivide that element into left and right halves, you need to imagine that the matrix was twice (two halves) as fine horizontally -- that it was 3 x 10 -- and then you figure out the element numbers that correspond to the two halves. A small calculation shows that the element numbers would be #19 and #20 of that finer grained matrix.
The step after that is to subplot() with those parameters:
subplot(3, 10, 19) or subplot(3, 10, 20)
and you would be addressing the left and right halves of the 3 x 5 element.
It is completely valid to subplot() with different granularities, as long as not of the axes that you subplot() into existence overlap any other one.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!