Problem plotting a Grantt Chart
1 次查看(过去 30 天)
显示 更早的评论
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)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888360/image.png)
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 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!