Setting box size in Figure

조회 수: 20 (최근 30일)
Dino Bergomi
Dino Bergomi 2022년 5월 6일
댓글: Dino Bergomi 2022년 5월 6일
Dear All,
I have been using matlab to generate figures with data. I typically set the figure size using "PaperSize", like in the example below, which works well for most cases. However, I would like to be able to set the size of the box instead (by box, I mean the space enclosed by the horizontal and vertical axes).
The reason for this is that often I try to put together different figures into a composite larger figure, and whenever the numbers in the axes have different formats (e.g. diferent decimals or powers), the box size is automatically adjusted. Hence, when I try to align the different individual figures, there is a mismatch... It is not a huge problem, but it affects my OCD a bit :)
As sort of a workaround I have been using subplot, but it is not optimal. It would be great to know if I can set the box size instead of the full figure.
Thanks
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', [4 2]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 4 2]);

채택된 답변

Jan
Jan 2022년 5월 6일
You can set the position (including the dimensions) of an axes as the "Position" (this is the InnerPosition), "TighInset" or "OuterPosition": https://www.mathworks.com/help/matlab/creating_plots/automatic-axes-resize.html
Use the PositionConstraint to avoid a rescaling (in Matlab < R2020a: "ActivePositionProperty").
  댓글 수: 1
Dino Bergomi
Dino Bergomi 2022년 5월 6일
The PositionConstraint works very well! Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by