フィルターのクリア

Problem plotting a Grantt Chart

1 回表示 (過去 30 日間)
Luís Silva
Luís Silva 2022 年 2 月 9 日
編集済み: Luís Silva 2022 年 2 月 9 日
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!

回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by