How do I draw barh using both axes values?

1 回表示 (過去 30 日間)
farzad
farzad 2020 年 4 月 27 日
コメント済み: Walter Roberson 2020 年 4 月 28 日
Hi All
How do I draw barh ( horizontal bars) taking into consideration both axes values : saying when 0<x<100 , draw a bar between 10<y<12
  1 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 27 日
Can you show an image of your expected output?

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 28 日
x_to_draw_at = x(0 < x & x < 100);
bar(x_to_draw_at, 12*ones(1,length(x_to_draw_at)), 'basevalue', 10)
  4 件のコメント
farzad
farzad 2020 年 4 月 28 日
dear Wiliam
there is a problem , I did the following :
ranged = ranges(0 < ranges & ranges < max(ranges)*1.1)
for the vertical axis of barh , but then the minimum limit on the axis goes to under zero, but I want the minimum level be always zero. how do I do that ?
Walter Roberson
Walter Roberson 2020 年 4 月 28 日
For values of ranges, by definition ranges <= max(ranges). When ranges is entirely positive, then max(ranges) is positive and max(ranges)*1.1 is even larger than max(ranges) so you can be sure that ranges < max(ranges)*1.1 .
So when could ranges < max(ranges)*1.1 be false?
  1. max(ranges) is 0, in which case 0*1.1 is 0, and 0 < 0 is false. On the other hand, the case of 0 is already eliminated by 0 < ranges
  2. max(ranges) is negative, in which case max(ranges)*1.1 is more negative, and it could be the case that there are some values that are more negative than max(ranges) but not as negative as max(ranges)*1.1. For example, -10.5 and -10, max() is -10, max()*1.1 is -11, and -10.5 < -11 is false. However, this can only happen for negative values, never for positive values, and you already eliminate negative values with 0 < ranges .
You should reconsider your test. Perhaps you want something like max(ranges)*0.9
by the way , the bars should be horizontal. does the code do this ?
You are going to need to describe what the output should look like: we as outsiders need to assume that the x values are not sorted and not continuous.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by