通常,我希望将相当复杂的 x-y 图(很多重叠曲线)绘制成 A3 格式,因此:
A4 210x297
A3 = A4*2 = 420 x 297
... - 10mm each side = 400 x 277 (size of desired plot window)
设置绘图大小的最简单方法是什么,以便在以 PDF(或任何其他常见输出格式)打印时适合该大小?
最佳答案
作为@LewisNorton解释一下,你需要设置Paper***
properties图的。下面是生成尺寸为 420 x 297 mm
(A3 尺寸)的 PDF 文件的示例,其中绘图和文件边框之间的边距均为 10 mm
(顶部,底部,左侧,右侧)。
%# centimeters units
X = 42.0; %# A3 paper size
Y = 29.7; %# A3 paper size
xMargin = 1; %# left/right margins from page borders
yMargin = 1; %# bottom/top margins from page borders
xSize = X - 2*xMargin; %# figure size on paper (widht & hieght)
ySize = Y - 2*yMargin; %# figure size on paper (widht & hieght)
%# create figure/axis
hFig = figure('Menubar','none');
plot([0 1 nan 0 1], [0 1 nan 1 0]), axis tight
set(gca, 'XTickLabel',[], 'YTickLabel',[], ...
'Units','normalized', 'Position',[0 0 1 1])
%# figure size displayed on screen (50% scaled, but same aspect ratio)
set(hFig, 'Units','centimeters', 'Position',[0 0 xSize ySize]/2)
movegui(hFig, 'center')
%# figure size printed on paper
set(hFig, 'PaperUnits','centimeters')
set(hFig, 'PaperSize',[X Y])
set(hFig, 'PaperPosition',[xMargin yMargin xSize ySize])
set(hFig, 'PaperOrientation','portrait')
%# export to PDF and open file
print -dpdf -r0 out.pdf
winopen out.pdf
手边没有打印机,我正在使用虚拟 screen ruler检查测量结果;只需使用您喜欢的查看器显示 PDF 文件,并将缩放级别设置为 100%(我使用的是 Sumatra PDF )。如果您想自己尝试,请注意某些查看器 (Adobe Reader) 可能使用的自定义 DPI 与系统默认分辨率(我的分辨率为 96 像素/英寸)不匹配。
在这里您可以看到底部和左边距等于 10mm
。其他两个边距也是如此:
请注意,在上面的示例中,我使轴覆盖了整个图形(图中没有灰色区域)。默认情况下,MATLAB 会为刻度标签、轴标签、标题等留出一些空白空间。这当然与上面提到的边距不同,我假设您已经知道:)
关于matlab - 如何将matlab中的绘图设置为特定大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7561999/