universalis
universalis

Reputation: 41

Subplots with same height in MATLAB

I have something like

subplot(2,2,1)
plot(y1)
subplot(2,2,3)
plot(y2)
subplot(2,2,[2 4])
plot(y3)

The last plot plotting y3 does not get the same height as the plots y1 + y2. How can I fix this?

Hugh Nolan is right. There shouldn't be any problem in general. However, boxplots seem to shrink automatically after being plotted.

How can I get the boxplot to have the same height as the side-by-side subplots?

Upvotes: 4

Views: 5062

Answers (3)

Pranav
Pranav

Reputation: 52

Did you try axes/axis function? That sets the xlim and ylim of the graph.

Upvotes: 0

user2482876
user2482876

Reputation: 298

You can manually specify the position, width and height of each subplot by using subplot('Position',[left bottom width height]) instead of the habitual subplot command. For more info see the Mathworks page.

Upvotes: 0

Hugh Nolan
Hugh Nolan

Reputation: 2519

The ylim function allows you to get and set the limits of the y axis, so you could do:

subplot(2,2,1)
plot(y1)
yl1=ylim;
subplot(2,2,3)
plot(y2)
ylim(yl1);
subplot(2,2,[2 4])
plot(y3)
ylim(yl1);

Upvotes: 1

Related Questions