Plotting 3 differing intervals of time in a bar style to show when an interval is occuring
1 回表示 (過去 30 日間)
古いコメントを表示
I have 3 intervals of time (attached as data matrix - subdivided into a,b,c). These intervals divide the timeline (attached as time matrix) based on other data not attached. I would like to plot the data in a bar under the timeline to show when each interval is occurring. I have attached an example of something I would like it to look like, although the real data is randomly interspersed.
Please let me know if something is not clear. Any help would be greatly appreciated.
0 件のコメント
採用された回答
jonas
2018 年 10 月 16 日
編集済み: jonas
2018 年 10 月 16 日
I'll admit that I misunderstood the question the last time it was posted. However, the general approach still works the same.
%Load data
data = load('data matrix.mat');
t = load('time matrix.mat');
% Concatenate a,b,c with grouping variable
ts = [data.a,ones(size(data.a,1),1);data.b,ones(size(data.b,1),1).*2;data.c,ones(size(data.c,1),1).*3];
% Sort and make continous
ts = sortrows(ts,1);
td = ts(:,2)-ts(:,1); %Durations
td = cumsum(td);
% Make surface bar
n=length(td);
X=[td';td'];
Y=[1.1.*ones(1,n);0.9.*ones(1,n)];
colormap(lines(3))
Z=ts(:,3)';
Z=[Z;Z];
surf(X,Y,Z)
view([0 90])
set(gca,'ycolor','none')
.
Does it look alright? Note that the black stripes are edges that divide segments. You can remove those by setting the 'edgecolor' to 'none' in the surf call, getting this instead:
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!