How do I insert more space between my x-axis ticklabels and the xlabel string in my figure?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
MathWorks Support Team
am 27 Jun. 2009
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!