Remove the bottom x-axis line of a plot

585 visualizaciones (últimos 30 días)
TTA
TTA el 26 de Mayo de 2022
Comentada: TTA el 27 de Mayo de 2022
Hi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks

Respuesta aceptada

TTA
TTA el 26 de Mayo de 2022
Please I want to do something like this that will remove only the bottom x-axis
  2 comentarios
Veronica Taurino
Veronica Taurino el 27 de Mayo de 2022
Editada: Veronica Taurino el 27 de Mayo de 2022
Use this to remove even the x-tick label as in the above picture:
plot(1:10) % your plot here
set(gca,'XAxisLocation','top', 'box','off', 'XTick', [])
If you need labels:
set(gca,'XAxisLocation','top', 'box','off')
Look here and here
TTA
TTA el 27 de Mayo de 2022
Thank you very much.
It works

Iniciar sesión para comentar.

Más respuestas (1)

Veronica Taurino
Veronica Taurino el 26 de Mayo de 2022
Editada: Veronica Taurino el 26 de Mayo de 2022
In general, to move your x-asix on top:
set(gca,'XAxisLocation','top')
To hide the axis:
set(gca,'xtick',[])
or
h = gca;
h.XAxis.Visible = 'off';
  2 comentarios
TTA
TTA el 26 de Mayo de 2022
Thanks Vero,
In this case will I be able to turn off only the bottom x-axis off and leave the top x-axis?
Thanks
Veronica Taurino
Veronica Taurino el 26 de Mayo de 2022
Editada: Veronica Taurino el 26 de Mayo de 2022
I gave you more options because your need is not clear to me. You should try one of the above. I think the first one could be fine:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
set(gca,'XAxisLocation','top')

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by