Hello
I would like to add/show specific numbers in x-axis.Like numbers I showed here 52 and last number 142.

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 2 月 27 日

0 投票

Use the xticks and possibly xticklabels function.
x=0:142;
y=linspace(0.1, 2.7,length(x));
bar(x,y)
xline(52,'m--')
xticks(sort([xticks 52 142]));

4 件のコメント

Brave A
Brave A 2021 年 2 月 27 日
編集済み: Brave A 2021 年 2 月 27 日
Thanks but the last 2 numbers overlapping, how to fix that please?
I want only 142.
Cris LaPierre
Cris LaPierre 2021 年 2 月 27 日
編集済み: Cris LaPierre 2021 年 2 月 27 日
That's because the ticks are too close to each other.
You could try rotating the labels
The solution I would recommend is to remove 140 as a tick.
ax=gca;
ax.XTick(end-1)=[];
Brave A
Brave A 2021 年 2 月 27 日
One more question please, how to remove 0/zeros from axis?
Cris LaPierre
Cris LaPierre 2021 年 2 月 27 日
Which zeros do you want removed?
You could either
  • delete or rename the tick label
  • delete or move the tick
  • change you axis limits to not include 0

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by