Plotting 3 differing intervals of time in a bar style to show when an interval is occuring

3 ビュー (過去 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.

採用された回答

jonas
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:
  8 件のコメント
Systematically Neural
Systematically Neural 2018 年 10 月 17 日
Ok, what does the variable 'cmap' refer to?
jonas
jonas 2018 年 10 月 17 日
Ops, add cmap before the call to colormap
cmap = colormap(...)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by