Creation of a "Status Bar" plot, displaying machine statuses (ON, OFF, Standby)
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
Is there a way to create a subplot like the lower one in the picture?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164898/image.jpeg)
I have 2 matrices for the statuses of n machines, one for the ONs, one for the standbys, S_on and S_sb. A '1' in each of those matrices represents on or standby, '0' in both mean off. To create the final matrix with the power Consumption, each of them will be multiplied with a Power vector.
Now I want to create a status bar beneath indicating when the machine is ON, standby or OFF. How do I plot this? Thank you so much for your help!
Simon
0 个评论
回答(1 个)
Azzi Abdelmalek
2014-6-28
编辑:Azzi Abdelmalek
2014-6-28
x=[0 1 1 2 2 4 4 5 ]
y=[2 2 1 1 0 0 2 2]
subplot(211),plot(x,y)
subplot(212),
in={'off','sb','on'}
cl={'g','b','y'}
for k=1:numel(x)/2
xx=x(2*k-1:2*k )
plot([ xx fliplr(xx) xx(1)],[0 0 1 1 0],cl{y(2*k)+1},'linewidth',12)
text(mean(xx),0.5,in{y(2*k)+1},'fontsize',12)
hold on
end
hold off
另请参阅
类别
在 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!