Filter löschen
Filter löschen

HORIZONTAL BAR PLOT WITH GAPS

10 Ansichten (letzte 30 Tage)
Lucas campos
Lucas campos am 3 Nov. 2020
Bearbeitet: Mario Malic am 3 Nov. 2020
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

Antworten (1)

Mario Malic
Mario Malic am 3 Nov. 2020
Bearbeitet: Mario Malic am 3 Nov. 2020
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.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by