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]);

 Respuesta aceptada

Jan
Jan el 6 de Mayo de 2022

0 votos

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 comentario

Dino Bergomi
Dino Bergomi el 6 de Mayo de 2022
The PositionConstraint works very well! Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 6 de Mayo de 2022

Comentada:

el 6 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by