How to display interval data on x axis in histogram plot (eg. 10-20, 20-30,...) ?

13 ビュー (過去 30 日間)
Avantika Vijay Bharati
Avantika Vijay Bharati 2022 年 8 月 3 日
コメント済み: Star Strider 2022 年 8 月 3 日
I want to plot the data for x axis readings as 10-20, 30-40, 50-60 upto 190-200 for the repsctive y axis values as below in MATLAB. I tried using xlim or XTick but its not showing up the x axis in interval format.
x_ax_data = [10-20, 30-40, 50-60, 70-80, 90-100]
y_ax_data = [0, 0, 200, 550, 920]

回答 (1 件)

Star Strider
Star Strider 2022 年 8 月 3 日
編集済み: Star Strider 2022 年 8 月 3 日
Try this —
x_ax_data = ["10-20", "30-40", "50-60", "70-80", "90-100"]; % Create String Vector
y_ax_data = [0, 0, 200, 550, 920];
figure
bar(y_ax_data)
xticklabels(x_ax_data)
.
  2 件のコメント
Avantika Vijay Bharati
Avantika Vijay Bharati 2022 年 8 月 3 日
It works :)
Thank you so much...!
Star Strider
Star Strider 2022 年 8 月 3 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by