Remove the bottom x-axis line of a plot

227 views (last 30 days)
TTA
TTA on 26 May 2022
Commented: TTA on 27 May 2022
Hi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks

Accepted Answer

TTA
TTA on 26 May 2022
Please I want to do something like this that will remove only the bottom x-axis
  2 Comments
TTA
TTA on 27 May 2022
Thank you very much.
It works

Sign in to comment.

More Answers (1)

Veronica Taurino
Veronica Taurino on 26 May 2022
Edited: Veronica Taurino on 26 May 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 Comments
Veronica Taurino
Veronica Taurino on 26 May 2022
Edited: Veronica Taurino on 26 May 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')

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!