How can I reduce the distance between the numbers of Xaxis and the plot?
조회 수: 8 (최근 30일)
이전 댓글 표시
Any way to change the distance between the numbers and the actual plot?
댓글 수: 3
Star Strider
2016년 2월 23일
One option is to simply reduce the font size of the tick labels.
Otherwise, to the best of my knowledge, there is no way to adjust that. You would have to turn them off (easily enough done) and then replace them with a text object (also easily enough done).
The problem is that the text object distance from the x-axis may not scale properly if the plot size changes.
I would search Yair Altman’s Undocumented MATLAB site. If there is a way to change the distance and have it scale properly, you will find it there.
Dek Na
2018년 9월 29일
편집: Dek Na
2018년 9월 30일
This answer on StackOverflow worked for me: https://stackoverflow.com/a/45103006. S2 value depends on your figure size and does not scale like the regular tick values. If you change the last line of code to be
ax.XTickLabel = [' ']; %instead of: ax.XTickLabel = [];
you prevent the XLabel from overlapping the XTickLabel. Maybe someone could modify that code to shift YTickLabel as well. I tried without success.
답변 (3개)
Explorer
2016년 2월 23일
편집: Explorer
2016년 2월 23일
% Distance between x-axis is 1 units
x=0:1:50;
y=sin(x);
subplot(2,1,1), plot(x,y)
% Reducing distance between x-axis to 0.5 units
x=0:0.5:50;
y=sin(x);
subplot(2,1,2), plot(x,y)
Generally, this is how we reduce spacing size of x-axis. To know specifically, you have to show us the case in which you want reduction.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!