How to use boxes to plot a freqency band?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'd like to create a plot that looks similar to this:
Row1:| [_____] [_______] [_] [___] [___________]
Row2:| [________] [_] [______] [_________]
|____________________________________________________
Frequency
The idea is that Row1 and Row2 contain frequency spans that I would like to identify with boxes.
I can't seem to make the horizontal bar graph do something like this.
Any help is greatly apprecited. Thanks all!
댓글 수: 0
답변 (2개)
Rick Rosson
2011년 8월 30일
You may want to consider using patch objects. For more information:
>> doc patch
HTH.
Rick
댓글 수: 0
Oleg Komarov
2011년 8월 31일
% I suppose you have the starting and ending point of each block. % You have to ensure that they are monotonically increasing across rows and the number of columns is even.
sten = [1 3 7 14 16 17;
2 4 8 9 11 19];
% Create X coordinates for the boxes
clear X
szSt = size(sten);
df = diff(sten,[],2);
X(:,1:2:szSt(2)*2) = [sten(:,1) df];
X = [cumsum(X,2) sten(:,end)];
% Create the Y coordinates for the boxes
Y = repmat(bsxfun(@minus,[2.5; 1.5; 1.5; 2.5],0:szSt(1)-1), szSt(2)/2,1);
% Reshape
X = reshape(X.',4,[]);
Y = reshape(Y,4,[]);
% Figure and axes
figure('units','pix','pos',[300 200 640 140])
axes('units','pix','pos',[20 20 600 100],'Xlim',[0 max(sten(:))+1],...
'Ylim',[0 szSt(1)+.5],'Ytick',1:szSt(1),'YtickL',szSt(1):-1:1)
patch(X,Y,ones(size(X)))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!