Figures don't resize, but axes do (with almost the same commands)
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Harsha Medikonda
2015-7-9
Can u attach a screenshot? At my end I do not see the behavior you are describing.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!