필터 지우기
필터 지우기

HORIZONTAL BAR PLOT WITH GAPS

조회 수: 10 (최근 30일)
Lucas campos
Lucas campos 2020년 11월 3일
편집: Mario Malic 2020년 11월 3일
Hello,
I have a set of data with a timestamp and the state of two machines. When the machine is turned on I have 1. If turned off, I have 0.
I would like to plot using horizontal bars when each machine is working. Also, I would like to plot the total time in minutes inside the bar.
Any ideas on how to do it?
Thanks a lot
Lucas

답변 (1개)

Mario Malic
Mario Malic 2020년 11월 3일
편집: Mario Malic 2020년 11월 3일
Here is the heatmap solution, but unfortunately it doesn't return the total time in bar.
clc;
clear;
close all;
M1 = [ones(1,6), zeros(1,4), ones(1,7), zeros(1,3)];
M2 = [zeros(1,5), ones(1,6), zeros(1,5), ones(1,4)];
t1 = datetime(2020,10,26,0,0,0);
t2 = datetime(2020,10,26,19,0,0);
t = (t1 + hours(0:19));
h = heatmap(t, {'Machine 1', 'Machine 2'}, [M1; M2]);
There is a helpful link at Stackoverflow, if you'd like to make it using barh. Also, it is possible to overlay the text with the color background and the total number, but you'd have to generalise the calculation and location, width and height to place it. This is totally doable and could be worthy of file exchange submission.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by