multiple plots on a subplot
83 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Azzi Abdelmalek
il 19 Feb 2013
Modificato: Azzi Abdelmalek
il 19 Feb 2013
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 Commenti
Più risposte (1)
Walter Roberson
il 19 Feb 2013
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 Commenti
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!