Axes automatically change size and get mis-aligned in App Designer

16 visualizaciones (últimos 30 días)
Kristoffer Walker
Kristoffer Walker el 21 de En. de 2021
Comentada: Jiri Hajek el 8 de Jun. de 2021
Hello Matlab Community!
Happy New Year! Hope you all have a productive year coding your hearts away to solve important problems!
One of the very few issues I have been having in Matlab recently has been App Designer's automatic adjustment of axes after plotting. I pre-define the size of my axes so that they are aligned in a 2 x 2 matrix fashion. I push a button and all 4 axes are populated with data. Then an automatic size adjustment of the axes occurs. This causes them to not be aligned and look unprofessional, and in some cases, makes it difficult to correlate between axes when they share the same axis min/max values. Is there any simple way to fix this? Is this fixed or is there an option to "freeze" axes dimensions in newer versions? I have also tried using the Grid Layout option, but that did not prevent the automatic size adjustements.
Attached are screen shots before (aligned, as shown in App Designer) and after (misaligned).
Best regards,
Kris
  1 comentario
Jiri Hajek
Jiri Hajek el 8 de Jun. de 2021
Kris, I just had the same problem. To solve it, I had to switch off AutoResizeChildren property under Position of the parent container and add a "Size changed function" callback for the same parent container. In there, I re-aligned the axes as required.

Iniciar sesión para comentar.

Respuestas (1)

Matt Gaidica
Matt Gaidica el 22 de En. de 2021
Kris, one thing you can do is get the position property from all axes before you populate the data and then set it again afterwards.
% before
pos = get(AxesHandle,'Position');
% after
set(AxesHandle,'Position',pos);
  1 comentario
Kristoffer Walker
Kristoffer Walker el 23 de En. de 2021
Hi Matt,
Thanks for the reply and your idea!
I just tried it, but it does not have an effect either in a canvas without a grid or in a "grid-converted" canvas. The set command reports the following warning:
Warning: Unable to set 'Position', 'InnerPosition', or 'OuterPosition' for components in 'GridLayout'.
Perhaps this worked in GUIDE in the past, but maybe not in App Designer?
Best regards,
Kris

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by