Remove the bottom x-axis line of a plot

371 次查看(过去 30 天)
Hi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks

采纳的回答

TTA
TTA 2022-5-26
Please I want to do something like this that will remove only the bottom x-axis
  4 个评论
DLR
DLR 2024-10-4
Removing the box also seems like it removes the right y-axis. Is there any way to avoid this?
Les Beckham
Les Beckham 2024-10-4
编辑:Les Beckham 2024-10-4
If you just want to restore the right side of the box (without ticks or tick labels on the right side), you could do this:
plot(1:10)
set(gca,'XAxisLocation','top', 'box','off')
xline(max(xlim)) % <<< this draws the right side of the "box"

请先登录,再进行评论。

更多回答(1 个)

Veronica Taurino
Veronica Taurino 2022-5-26
编辑:Veronica Taurino 2022-5-26
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 个评论
TTA
TTA 2022-5-26
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 2022-5-26
编辑:Veronica Taurino 2022-5-26
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')

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by