# How can I reduce the distance between the numbers of Xaxis and the plot?

18 visualizaciones (últimos 30 días)
Armindo el 23 de Feb. de 2016
Editada: David el 23 de Abr. de 2019
Any way to change the distance between the numbers and the actual plot?
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Star Strider el 23 de Feb. de 2016
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 el 29 de Sept. de 2018
Editada: Dek Na el 30 de Sept. de 2018
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.

Iniciar sesión para comentar.

### Respuestas (3)

Explorer el 23 de Feb. de 2016
Editada: Explorer el 23 de Feb. de 2016
% 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 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Armindo el 23 de Feb. de 2016
Editada: Armindo el 23 de Feb. de 2016
Yes Amos you are right.
The distance between the numbers displayed below the plot and the box limit (bottom plot limit or the x-axis line)
I have several subplots and I need to put the numbers very close to the X-axis line to save space.
Explorer I dont want the horizontal distance between numbers I want the vertical distance between the X-axis line and the numbers. In other words I want to put the numbers just below the X-axis line.
##### 2 comentariosMostrar NingunoOcultar Ninguno
Explorer el 23 de Feb. de 2016
Editada: Explorer el 23 de Feb. de 2016
I still did not get what actually you want to do. Can you upload your stuff here?
Armindo el 23 de Feb. de 2016
________________ Axis
0 1 2
________________ Axis (I want this without space between line and numbers)
0 1 2

Iniciar sesión para comentar.

David el 23 de Abr. de 2019
Editada: David el 23 de Abr. de 2019
I would also like an answer to this question.
I've tried making the tick label interpreter latex and then adding \vspace{-1mm} calls but all whitespace commands seem to be ignored.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Grid Lines, Tick Values, and Labels en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by