Remove the bottom x-axis line of a plot

조회 수: 586 (최근 30일)
TTA
TTA 2022년 5월 26일
댓글: TTA 2022년 5월 27일
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
  댓글 수: 2
Veronica Taurino
Veronica Taurino 2022년 5월 27일
편집: Veronica Taurino 2022년 5월 27일
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 2022년 5월 27일
Thank you very much.
It works

댓글을 달려면 로그인하십시오.

추가 답변 (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에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by