为什么轴位置的实际值与MATLAB suplot图中的导出值不同?

为什么轴位置的实际值与MATLAB suplot图中的导出值不同?,matlab,plot,axes,Matlab,Plot,Axes,我有一个数字显示了两个子图。我希望获得每个绘图的轴位置,因此我使用图形的子项信息: subplot(211) % Plot stuff here ... subplot(212) % Plot stuff here ... % Get Axes Position information f =gcf; % Bottom Plot Axis disp(f.Children(2).Position) % Top Plot Axis disp(f.Children(4).P

我有一个数字显示了两个子图。我希望获得每个绘图的轴位置,因此我使用图形的子项信息:

 subplot(211)
 % Plot stuff here
 ...
 subplot(212)
 % Plot stuff here 
 ...

 % Get Axes Position information
 f =gcf;
 % Bottom Plot Axis
 disp(f.Children(2).Position)
 % Top Plot Axis
 disp(f.Children(4).Position)
控制台显示:

 Bottom plot:
     0.1300    0.1100    0.7750    0.3412

 Top plot:
     0.1300    0.5838    0.7750    0.3412
考虑到所有其他因素,这似乎是正确的。当我运行绘图生成图形,然后通过“显示绘图工具和停靠图形->检查器:matlab.graphics.axis.axis”选项检查轴信息时,每个轴位置的宽度值不是0.7750。其他位置值如所列,但顶部和底部绘图的宽度不同。顶部变为[0.13 0.5838 0.682 0.341],底部变为[0.13 0.11 0.67 0.341]

是否有人知道这是为什么,以及如何获得“真实”位置值,而不是不正确的显示/打印值

有用信息:MATLAB R2014b

编辑更新: 这是一个产生行为的MWE

clear all; close all; clc; 
figure; 

subplot(211)
hold on

x1 = [ -1 -0.998 -0.996 -0.994 -0.992];
y = [0.000324249267578125 -0.000370025634765625 -3.4332275390625e-005 -0.000186920166015625 -0.000110626220703125];
plot(x1, y, '-', 'MarkerSize', 10) 

set(gca, 'FontName', 'Interstate-Light', 'FontSize', 7)
set(gca, 'XTickLabel', [])
set(gca, 'XLabel', [])
grid on
ylabel('Frequency Error (Hz)', 'FontName', 'Interstate-Bold')
legend({'FE'}, 'Location', 'NorthEastOutside', 'FontName', 'Interstate-Light', 'Box', 'off')

subplot(212)
hold on
x1 = [ -1 -0.998 -0.996 -0.994 -0.992];
y = [-0.010614013299346 -0.0417663566768169 0.0235949698835611 -0.0502893067896366 0.0316442884504795];
plot(x1, y, '-', 'MarkerSize', 10) 

% Overide X-axis ticks to align with data
XTick = unique(x1);

grid on;
xlabel('Time (s)', 'FontName', 'Interstate-Bold')
ylabel('Frequency Error (Hz)', 'FontName', 'Interstate-Bold')
set(gca, 'FontName', 'Interstate-Light', 'FontSize', 7)
legend({'RFE'}, 'Location', 'NorthEastOutside', 'FontName', 'Interstate-Light', 'Box', 'off')

% Get figure object
f = gcf;
% Set fontsize to 16 for readability in final pdf
set(findall(f, '-property','FontSize'),'FontSize',16)
f.PaperUnits = 'inches';
f.PaperPosition = [0 0 20 14];
f.PaperPositionMode = 'manual'; 

% Get axis position info
disp('Second plot:')
disp(f.Children(2).Position)
disp('First Plot:')
disp(f.Children(4).Position)

我正在使用
R2012b
,我能够重现问题,并且(几乎)能够理解发生了什么

我不知道它是否也适用于更“新”版本的MatLab

该问题似乎与窗口的
默认配置
显示打印工具和停靠图有关

使用此配置,实际上,两个轴的
位置
(在
属性编辑器
中读取)与“原始轴:

original pos ax 1=  [0.1300    0.5838    0.7750    0.3412]
new pos ax1=[0.1300    0.629     0.7750    0.268 ]
但是,如果
最小化
属性编辑器
选项卡并查看两个轴的
位置,它们将恢复为“原始”一个值

您可以,选项卡的“向上滑动”和
位置仍然保持“原始onne”

我不知道这是否真的是对你问题的回答;我能说的是,正确的位置是“原始”位置

这可能是默认配置中显示绘图工具和停靠图窗口的一种缺陷

希望这有帮助


我无法用提供的代码和步骤重现此问题。停靠图形是否会改变窗口的几何图形?或者这不应该是问题?@AndrasDeak由
子地块生成的轴的默认单位是
标准化的
,不应该随窗口的几何图形而改变。@excaza强调“不应该”?:)@AndrasDeak如果你能证明这一点,请放心。这不仅是因为可视化效果不稳定,而且当我进入每个轴的检查器时,位置值不是控制台中显示的值。此外,当我将图形保存为png时,它显示的是“不同”的位置值,而不是控制台打印出来的值。s直到无法修复。