Borrar filtros
Borrar filtros

Problem plotting a Grantt Chart

1 visualización (últimos 30 días)
Luís Silva
Luís Silva el 9 de Feb. de 2022
Editada: Luís Silva el 9 de Feb. de 2022
Hi all,
I'm trying to plot a Gantt chart to better read my results and i've been facing a problem,
So im plotting a scheduling problem where a task (my y-axis) is done in the time-window (x-axis) by a certain team of type z.
considering my p matrix where collumn 1 is the team that does the the task, collumn 2 the start period and collumn 3 the end period i've managed to create the chart i want with a problem: i cant turn certain teams invisible for each bar:
my code so far:
b=6;
e=8;
p=[6 1 5 0
3 1 4 0
1 1 3 1
1 5 6 0
1 3 5 1
2 1 7 0];
D=zeros(b,e+1);
for i=1:b
D(i,p(i,1)+1)=p(i,3)-p(i,2);
D(i,p(i,1))=p(i,2);
end
hBar = barh(D,'stacked');
hBar(1).Visible='off';
yt = get(gca, 'YTick');
B=zeros(1,b);
C=zeros(1,e);
for i=1:b
B(i)=i;
end
for i=1:e
C(i)=i;
end
set(gca, 'YTick', yt, 'YTickLabel', {B})
size(D,1)
ans = 6
yjob(1)={''};
for i=2:e+1
yjob(i) = {C(i-1)};
end
barbase = cumsum([zeros(size(D,1),1) D(:,1:end-1)],2);
joblblpos = D/2 + barbase;
for k1 = 1:size(D,1)
text(joblblpos(k1,:), yt(k1)*ones(1,size(D,2)), yjob, 'HorizontalAlignment','center')
end
the result i get is this: (x marks the ones i wanted to remove to finish the chart) which is really close but not exactly
i there it even possible to do this? i went this way because i cant seem to make work of a way to name or color each bar individualy depending on the values of p(i,1) to easily see which team did what task.
Many thanks!

Respuestas (0)

Categorías

Más información sobre App Building en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by