Effacer les filtres
Effacer les filtres

How to do one grouped graph showing months

3 vues (au cours des 30 derniers jours)
Ro
Ro le 6 Mai 2021
Réponse apportée : KSSV le 6 Mai 2021
If I want a grouped graph with x axis being Jan to Dec. But Jan has cyclist data for 3 diff days, feb has data for 7 diff days of the month, March has for 22 diff days of the month etc How do I make Jan with 3 grouped bars, feb with 7 grouped bars, March with 22 diff grouped bars etc. Without each months data crossing each each other. Eg if Jan 16th has cyclist data, and Feb 16th has cyclist data, I want to ensure they keep separate under their matching months.

Réponses (1)

KSSV
KSSV le 6 Mai 2021
t = datetime(2020,1,1):datetime(2020,12,31) ;
y = rand(size(t)) ;
% make required dates to plot
jan_t = datetime(2020,1,[10 12 14]) ;
feb_t = datetime(2020,2,[1,3,7,8,10,12,14]) ;
mar_t = datetime(2020,3,[12, 15,20,22, 23, 24, 25, 27]) ;
ti = [jan_t feb_t mar_t] ;
% plot
[idx,ia] = ismember(t,ti) ;
bar(ti,y(idx))

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by