# How do I show a subplot next to the other one?

28 Ansichten (letzte 30 Tage)
Mary Cosner am 15 Feb. 2015
Beantwortet: James Spriggs am 16 Feb. 2015
I would like to do a comparison of two plots. How do I get the two plots to be shown next to each other in the same figure?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (3)

Rick Rosson am 15 Feb. 2015
figure;
subplot(1,2,1);
plot(...);
subplot(1,2,2);
plot(...);
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

James Spriggs am 16 Feb. 2015
When you use the subplot tool you want to format your code like so:
subplot(x,y,z)
This will not actually plot any data, but it will specify the size and position of your subplot window. The first number (x) describes the number of rows of subplots you want. The second number (y) describes the number of columns of subplots you want. Finally, the last number (z) describes the position of the subplot that will be graphed when you use the plot function in the next line. Essentially, the first two numbers create a matrix of possible subplots. These cells are then assigned a single digit number that increases from left to right, top to bottom. Therefore, if I gave the following commands:
figure1;
subplot(2,3,3);
plot(...);
the graph would appear on the left hand side in the middle. The five other unassigned subplot cells would remain blank until you created more subplots.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Mariah Villanueva am 16 Feb. 2015
figure(...); subplot (1,2,1); plot(x1,y1); subplot (1,2,2); plot(x2,y2);
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Subplots finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by