通常默认情况下,print命令输出图像为8*5inches,无视屏幕显示尺寸
通过命令行修改的话有三步
1设置paperposition为manual
set(gcf,'PaperPositionMode','manual')
[ auto |{manual} ]
2设置paperunit
set(gcf,'PaperUnits')
[ {inches}| centimeters | normalized | points ]
3设置paperposition
set(gcf,'PaperPosition',[left,bottom,width,height])
例如
set(gcf,'PaperPositionMode', 'manual');
set(gcf,'PaperUnits', 'points');
set(gcf,'PaperPosition', [0 0 640 480]);
还有一个相关命令是papersize
paperposition是placement,代表图像在paper中的所处位置。left和bottom计算好,就可以使图像在paper中居中
papersize是纸张大小;position要比size小的
PaperPosition
要使图像比例输出与屏幕显示的一致,可以使用如下命令
屏幕显示图像尺寸可以plot时用set(gcf,'position',[left bottom width height])调整,或者print之前拖动窗口手动调整
This example exports a figure atscreen size to a 24-bit TIFF file, myfigure.tif.
set(gcf, 'PaperPositionMode','auto')
print -dtiff myfigure
==================================================================================================================================================================================================================================================================
单位("units")属性的默认值为像素(pixels),但是它的属性值还可以为英尺(inches),公分(centimeters),点(points),或归一化坐标(normalixedcoordinates)。像素代表了屏幕像素,即在屏幕上可表示出来的最小的对象。典型的计算机屏幕最小分辨为640×480,在屏幕的每一个位置都有超过 1000的像素。因为像素数因机算机屏幕的不同而不同,所以指定对象的大小也会随之改变。
归一化坐标是在 0到1范围内。在归一化坐标中,屏幕的左下角为[0,0]右上角为[1.0, 1.0]。
H =figure(1)
set(H,'units','normalized','position',[0 .5 .5.45])
好的编程习惯:如果你想把对象放置在窗口的特定位置,最好的方法是用归一化坐标,因为不用考虑显示器的大小。
联系客服