필터 지우기
필터 지우기

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 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