图形尺寸限制

时间:2016-03-30 16:04:40

标签: matlab matlab-figure figure

在回答这个question期间,与问题无关的问题,通过创建高度非常高的数字,我发现数字被裁剪了。如果数字子项的'units'属性设置为'normalized',则相应的子项会缩小而不会被裁剪。

问题是,为什么数字的高度受限制以及限制的(属性)规则。看起来我的身高只有9.94英寸(戴尔Latitude E5500; Win7输入,32位; matlab 2011b;分辨率1400x900像素)

修改

我试过了:

>> set(gcf,'position',[10 10 600 600]),get(gcf,'position')

ans =

 10.0000   10.0000   28.3333    9.8750

>> set(gcf,'position',[0 0 600 600]),get(gcf,'position')

ans =

 0     0   600   600

export_fig获得的数字在两个案例中均为28.35“x 9.88”(在Adobe Acrobat 9 Pro中测量)。

1 个答案:

答案 0 :(得分:2)

我怀疑它与Matlab检测到的最大显示尺寸和系统的像素密度有关。

在我的Matlab R2013a,Windows 7,屏幕1900x1200上,我可以获得比你更大的数字,但它仍然会被截断:

%% // MATLAB R2013A - Windows 7, 1900x1200pixels
set(gcf,'units','inches','position',[1 -5 6 15])
get(gcf,'position')
get(gcf,'OuterPosition')

返回:

ans =
          1.00         -5.00          6.00         11.81
ans =
          0.92         -5.08          6.17         12.71

我的最大垂直图形尺寸被切割为11.81英寸。现在这是Matlab图的内部。包括标题栏和边框在内的实际尺寸由属性OuterPosition提供。

现在考虑:

>> get(0,'ScreenSize')
ans =
          1.00          1.00       1920.00       1200.00
>> get(0,'ScreenPixelsPerInch')
ans =
         96.00

如果我们做1200pixel / 96ppi = 12.5。有了这个屏幕密度,Matlab只能显示12.5英寸的图形。如果将单位设置为“像素”,这将是明显的模式:

set(gcf,'units','inches','position',[1 -5 6 15])
set(gcf,'units','Pixels')
get(gcf,'position')
get(gcf,'OuterPosition')
ans =
         97.00       -479.00        576.00       1134.00
ans =
         89.00       -487.00        592.00       1220.00

这个数字正好截断了1220像素(英寸单位只是一个转换,Matlab基本单位将以像素为单位)。我怀疑允许的额外20个像素是标题栏的额外余量。

现在有你的数字,我没有你的数字的outerposition,但即使数字内部位置也大致匹配你的屏幕尺寸(900px * 96ppi = 9.375英寸)。尝试强制单位回到Pixels,获得数字的OuterPosition,如果你得到920像素,我不会感到惊讶。

现在看来你只需要为旧版本的Matlab担心。在使用Matlab R2015b的同一台机器(Win 7,1900x1200px)上,不再需要自动裁剪:

%% // MATLAB R2015B - Windows 7, 1900x1200pixels
set(gcf,'units','inches','position',[1 -5 6 15])
get(gcf,'position')
get(gcf,'OuterPosition')
ans =
          1.00         -5.00          6.00         15.00
ans =
          0.92         -5.08          6.17         15.40
set(gcf,'units','Pixels')
get(gcf,'position')
get(gcf,'OuterPosition')
ans =
         97.00       -479.00        576.00       1440.00
ans =
         89.00       -487.00        592.00       1478.00

Matlab的新图形引擎似乎解除了这个限制,我的数字现在比我的屏幕尺寸大(无论你看像素还是英寸)。

相关问题