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!