Color Bar Classifying different time points
5 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197036/image.jpeg)
I have three sets of time - Time1, Time2, Time3. These three time points do not overlap. I would like to make a color bar to show when it is Time1, Time2 or Time3. this is hard to describe so I attached an image with the basic design. The idea being that this would continue for whatever times are in each of the three vectors.
Please let me know if I can clarify anymore.
採用された回答
jonas
2018 年 10 月 4 日
編集済み: jonas
2018 年 10 月 8 日
n=length(t_comb_2(:));
subplot(1,2,1);
x=t_comb_2;
x=x';
x=x(:)';
tic
X=[0 x;0 x];
Y=[1.1.*ones(1,n+1);0.9.*ones(1,n+1)];
colormap(lines(n+1))
Z=linspace(0,1,n+1);
Z=[Z;Z];
surf(X,Y,Z)
view([0 90])
set(gca,'ycolor','none')
axis tight
ylabel('time')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197046/image.jpeg)
.
Note that the colors were are determined by their z-value and the colormap lines. You can change the colormap and try different ones.
10 件のコメント
jonas
2018 年 10 月 16 日
Its a bar with different color segments... How can it not be what you asked? Do you want time1 and time2 plotted in the same bar?? Are they not overlapping?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Bar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!