I want to eliminate the margins of Axes, but it doesn't work.

18 ビュー (過去 30 日間)
cnrvx732
cnrvx732 2021 年 4 月 8 日
回答済み: cnrvx732 2021 年 4 月 8 日
I tried to remove the left and right margins with the following code, but it did not work.
I have set the width of the OuterPosition minus the margins on both sides of the TightInset to the Position, but the left margin does not disappear. Why is this?
When I moved the plot with the mouse, it was exactly the same width as the figure.
In the attached image, the margins are colored for clarity.
plot(rand(1,20))
ax = gca;
ax.OuterPosition(1)=0;
ax.OuterPosition(3)=1;
ax.Position(3)=ax.OuterPosition(3)-ax.TightInset(1)-ax.TightInset(3);

採用された回答

cnrvx732
cnrvx732 2021 年 4 月 8 日
I was solved this problem by inserting following code.
ax.Position(1)=ax.OuterPosition(1)+ax.TightInset(1);

その他の回答 (1 件)

Jan
Jan 2021 年 4 月 8 日
Try to set the 'Position' property instead:
plot(rand(1,20))
figure('Color', 'y')
ax = gca;
ax.Position(1) = 0;
ax.Position(3) = 1;
  1 件のコメント
cnrvx732
cnrvx732 2021 年 4 月 8 日
Thank you for your answer. I want to keep the tick labels and remove the useless margin. I can certainly do this by changing Position(1) and forcing the OuterPosition frame to be hidden outside the Figure, but is it possible to keep the OuterPosition frame inside the Figure and change the Position frame to eliminate the blank space?

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by