# How to change the height of the subplots without changing x,y-positions and width?

2 ビュー (過去 30 日間)
Wiqas Ahmad 2021 年 3 月 22 日

I have plotted three subplots in one figure which appeared in the upper side of the main figure window as shown. The bottom of the figure is almost empty. When I use position to set their heights, their x,y-postions and widths were also changed because position is a four-elements vector i.e. [left bottom width height]. How can I increase only the height of the subplots (not the whole figure) without changing other priorities so that the tile at the bottom became less obvious?
##### 1 件のコメント表示非表示 なし
Walter Roberson 2021 年 3 月 22 日
Did you use subplot() or did you use tiledlayout() ?

サインインしてコメントする。

### 採用された回答

Walter Roberson 2021 年 3 月 22 日
all_axes = reshape(get(gcf, 'type','axes'), 1, []);
for ax = all_axes
ax.Position(4) = 250; %or as appropriate
end
This will only change the height information without changing the lower left corner or the width.
I believe you will find it to be unsatisfactory. Positions are numbered from the bottom left corner and proceed upwards. When you increase the height without changing anything else, then they are left at the same anchor point but go even higher up... promptly running off the top. I would suggest to you that, contrary to your earlier thoughts, that you do want to change multiple position parameters. For example,
dh = 250; %or as appropriate
all_axes = reshape(get(gcf, 'type','axes'), 1, []);
for ax = all_axes
ax.Position(3:4) = ax.Position(3:4) + [-dh,dh];
end
This moves the lower limit further down the screen (closer to the bottom, which is 0) and at the same time adds an equal amount to the height, so that the top edge stays the same but the bottom gets lower.
##### 1 件のコメント表示非表示 なし
Wiqas Ahmad 2021 年 3 月 22 日
Thank you very much.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by