Effacer les filtres
Effacer les filtres

HORIZONTAL BAR PLOT WITH GAPS

10 vues (au cours des 30 derniers jours)
Lucas campos
Lucas campos le 3 Nov 2020
Modifié(e) : Mario Malic le 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

Réponses (1)

Mario Malic
Mario Malic le 3 Nov 2020
Modifié(e) : Mario Malic le 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.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by