Change divisions of x-axis on a bar graph

2 ビュー (過去 30 日間)
Nicola Caldognetto
Nicola Caldognetto 2020 年 4 月 23 日
コメント済み: Ameer Hamza 2020 年 4 月 24 日
So,
I'm generating a coin toss simulation with p(0) = 1 - p(1) where p(1) is 0.7
I've plotted the results in a bar graph with the code
bar([p_LOS p_NLOS],[p_LOS_count p_NLOS_count])
where p_LOS and p_NLOS are my probabilty (0.7 and 0.3) and p_LOS_count and p_NLOS_count are the counts, as the name suggest. The problem is when i plot with bar, the x-axis shows a subdvision as in the below figure instead of showing only the 0.3 and 0.7 point.
Is there a way to edit the axis?

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 23 日
Try this
p_LOS = 0.3;
p_NLOS = 0.7;
p_LOS_count = 125;
p_NLOS_count = 275;
fig = figure;
ax = axes();
b = bar([p_LOS p_NLOS],[p_LOS_count p_NLOS_count]);
ax.XTick = [p_LOS, p_NLOS];
  2 件のコメント
Nicola Caldognetto
Nicola Caldognetto 2020 年 4 月 24 日
It returns me error
Value must be a vector of type single or double whose values increase
Ameer Hamza
Ameer Hamza 2020 年 4 月 24 日
Can you show you code?

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

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by