我有一个我想调整大小的数字,然后打印成PDF格式。
使用类似的东西
set(hFig, 'PaperUnits', 'centimeters')
set(hFig, 'PaperSize', [x_B x_H]);只要我不调整太大的数字就行。如果我降低高度,那么xlabel会在某些点移出图形。我搜索了很多,但只找到一个解决方案来手动调整底层轴对象的大小
scalefactor = 0.96;
movefactor = 0.82;
hAx = get(gcf,'CurrentAxes');
g = get(hAx,'Position');
% 1=left, 2=bottom, 3=width, 4=height
g(2) = g(2) + (1-movefactor)/2*g(4);
g(4) = scalefactor*g(4);
set(hAx,'Position',g);我不喜欢这种方法,因为我必须手动调整这两个因素。
在打印之前,我将所有文本对象的“解释器”设置为“胶乳”(如果这是令人担忧的)。
打印使用
print(hFig, '-dpdf', '-loose', 'test.pdf');我希望通过使用'-loose'来放松边界框。任何帮助,高度赞赏!
编辑:
似乎真正的解释者(无,tex,乳胶)在此扮演一个角色。我在这里得到了这篇文章的启发(http://stackoverflow.com/questions/5150802/how-to-save-plot-into-pdf-without-large-margin-around),并提出了这个解决方案:
tightInset = get(gca, 'TightInset');
position(1) = tightInset(1);
position(3) = 1 - tightInset(1) - tightInset(3);
if strcmpi(x_Interpreter,'latex')
position(2) = tightInset(2)+ 1*tightInset(4);
position(4) = 1 - tightInset(2) - 2*tightInset(4);
else
position(2) = tightInset(2)+ 0*tightInset(4);
position(4) = 1 - tightInset(2) - 1*tightInset(4);
end
set(gca, 'Position', position);