Azzera filtri
Azzera filtri

HORIZONTAL BAR PLOT WITH GAPS

10 visualizzazioni (ultimi 30 giorni)
Lucas campos
Lucas campos il 3 Nov 2020
Modificato: Mario Malic il 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

Risposte (1)

Mario Malic
Mario Malic il 3 Nov 2020
Modificato: Mario Malic il 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.

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by