I have a number that I would like to change and subsequently print in PDF format. Using something like
set(hFig, 'PaperUnits', 'centimeters')
set(hFig, 'PaperSize', [x_B x_H]);
works until I resize the image too abruptly. If I reduce the height, at some points xlabel will exit the shape. I searched a lot, but found a solution to manually resize the main axis object
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);
I do not like this approach, since I have to manually configure two factors.
Before printing, I set the “interpreter” to “latex” of all text objects (if this is a concern). Printing is done using
print(hFig, '-dpdf', '-loose', 'test.pdf');
I was hoping to loosen the bounding box using '-loose'. Any help is much appreciated!
:
, (, , ). (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);