How do I insert more space between my x-axis ticklabels and the xlabel string in my figure?

조회 수: 4 (최근 30일)
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

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by