Setting box size in Figure

20 次查看(过去 30 天)
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").

更多回答(0 个)

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by