How do I draw barh using both axes values?

1 次查看(过去 30 天)
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

采纳的回答

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 CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by