Figures don't resize, but axes do (with almost the same commands)

3 visualizaciones (últimos 30 días)
Erik
Erik el 1 de Jul. de 2015
Comentada: Harsha Medikonda el 9 de Jul. de 2015
I resize axes to a certain resolution (seconds per centimetre) and I try to resize the figure's size accordingly. The figure won't resize properly with the following code. You can see the axes fall out of the figure's drawable area (the title and a portion of the upper axes area aren't visible). What am I doing wrong or how could I fix this issue?
EDIT: Additional info: If you add
close all
in front of the code below, I get a different and still erroneous result. The figure doesn't resize at all in this case. It remains at it's default size (which I've set in startup.m), but does move to the bottom left corner of the screen.
t = 0:100;
y = t;
% resolutions
rt = 10; % s/cm
ry = 10; % [y]/cm
plot(t,y);
title 'y vs. t'
xlabel 'time, [t] = s'
ylabel 'y'
% adjust axes and figure size
f = gcf;
a = gca;
f.Units = 'centimeters';
a.Units = 'centimeters';
f.OuterPosition(1:2) = 0; % move to bottom left corner of screen
ad = a.Position(3:4); % axes dimensions
% resize to set resolution
aw = range(t)/rt; % axes width
ah = a.YLim(2)/ry; % axes height
dd = [aw ah] - ad; % dimension difference
a.Position(3:4) = [aw ah]; % new axes dimensions
f.Position(3:4) = f.Position(3:4) + dd; % new figure dimensions
I'm on R2015a and Windows 8 x64.
  1 comentario
Harsha Medikonda
Harsha Medikonda el 9 de Jul. de 2015
Can u attach a screenshot? At my end I do not see the behavior you are describing.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by