Setting box size in Figure

20 vues (au cours des 30 derniers jours)
Dino Bergomi
Dino Bergomi le 6 Mai 2022
Commenté : Dino Bergomi le 6 Mai 2022
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]);

Réponse acceptée

Jan
Jan le 6 Mai 2022
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 commentaire
Dino Bergomi
Dino Bergomi le 6 Mai 2022
The PositionConstraint works very well! Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by