How to reduce space between axis labels and axis ticks?

조회 수: 133 (최근 30일)
Ammy
Ammy 2021년 9월 26일
댓글: Walter Roberson 2021년 9월 26일
x=1:54;
plot(x,y1,'k-+',x,y2,'b-*')
xlim([1 54]
xticklabel_rotate([1:54],90,D
xlabel('Sample 1')
ylabel('Sample 2')
How to reduce space between axis label and axis ticks, i,e., how to get axis label closer to axis.

답변 (1개)

Kevin Holly
Kevin Holly 2021년 9월 26일
x=1:54;
y1=cos(x);
y2=sin(x);
plot(x,y1,'k-+',x,y2,'b-*')
xlim([1 54])
xlabel('Sample 1')
ylabel('Sample 2')
Get the axes handle by using the command below
axes_handle = gca; %gca stands for get current axes
Now I am looking up the current position of the xlabel.
axes_handle.XLabel.Position
ans = 1×3
27.5000 -1.1409 -1.0000
The position in the x, y, and z-direction are 0.5, -0.0705, and 0, respectively.
Now, change the second value in the array. This will change the vertical position.
axes_handle.XLabel.Position = [27.5 -1.10 -1];
axes_handle.YLabel.Position
ans = 1×3
-3.1054 0.0000 -1.0000
Now, let's change the first value in the position array to move the ylabel horizontally.
axes_handle.YLabel.Position = [-2.6 0 -1];
  댓글 수: 4
Star Strider
Star Strider 2021년 9월 26일
@Noor Bano — There are specific windows provided for the Products and Release on the right side of this page. Please use them.
There is no previous mention of R2013a in this thread.
.
Walter Roberson
Walter Roberson 2021년 9월 26일
R2013a was mentioned in the comments in the question that this one is a duplicate of...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by