MATLAB: How to insert more space between the x-axis ticklabels and the xlabel string in the figure

axeslabel;MATLAB

I am trying to make my figure look better by inserting more space between the x-axis ticklabels and the xlabel string. However when I change the Position property of the xlabel and I try to print, using the PRINT command, to a Postscript format such as EPS, sometimes the xlabel string either moves into the axis grid or gets trimmed depending on whether its Units property is set to "data" or "normalized". This happens when the font size is big and the figure size is much larger than the paper size.
Reproduction Steps:
x=1:10;
y=1:10;
scrsz = get(0,'ScreenSize');
figH=figure('Position',[scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);
plot(x,y)
set(gca,'fontsize',20)
xlabel_h=xlabel('test','fontsize',20);
set(xlabel_h,'position',get(xlabel_h,'position')-[0 0.02 0]);
print -depsc img.eps

Best Answer

Changing the xlabel position property results in MATLAB treating the xlabel and the axis as two independent objects so that when the PRINT command resizes the figure to fit the paper, these two objects are not where they should be relative to each other.
As a workaround, use a multiline xlabel instead of changing the Position property.
x=1:10;
y=1:10;
scrsz = get(0,'ScreenSize');
figH=figure('Position',[scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);
plot(x,y)
set(gca,'fontsize',20)
xlabel_h=xlabel({'','test',''},'fontsize',20); %use cell array to construct multiline xlabel
print -depsc img.eps