Bar width according to a duration type data in a bar graph

조회 수: 5 (최근 30일)
Pietro Fedrizzi
Pietro Fedrizzi 2021년 11월 11일
댓글: Chunru 2021년 11월 12일
Hello everyone.
I have a bar graph which looks like this..
What I would like to do is modify this bar graph, so that each column gets a specific width according to a time interval (duration) that I have stored in a vector.
Other than that I wonder how can I insert a duration type vector in the x - axis of a bar graph, since what you see in this image are only xticks and xlabels of a specific istant of time of that duration time vector.
To sum up what I would like to obtain, is a bar graph like this, but on the x - axis there is a duration type data, and the column width corresponds to specific duration time intervals.
Thank you in advance, if I wasn't clear I can upload my code anytime.

답변 (1개)

Chunru
Chunru 2021년 11월 12일
편집: Chunru 2021년 11월 12일
x = 1:10; % x data
y = randi(10, size(x)); % y data
w = rand(size(x))/2; % width
for i =1 : numel(x)
bar(x(i), y(i), w(i), 'b');
if i==1, hold on; end
end
  댓글 수: 2
Pietro Fedrizzi
Pietro Fedrizzi 2021년 11월 12일
Thanks for answering, I understand now how to obtain different widths, but how do I implement this in my code where w(i) should be a duration time array? I'm still getting trouble...
Chunru
Chunru 2021년 11월 12일
Without providing data and your code, it is diffficult to give more help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by