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

3 ビュー (過去 30 日間)
Erik
Erik 2015 年 7 月 1 日
コメント済み: Harsha Medikonda 2015 年 7 月 9 日
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
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 ExchangeGraphics Object Programming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by