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 Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by