Plotting a Gantt Chart from a Matrix

조회 수: 19 (최근 30일)
Alaa Al-Saffar
Alaa Al-Saffar 2017년 12월 8일
편집: KSSV 2024년 8월 1일
Hello,
I plotted this gantt chart in excel using this table.
The Gantt Chart looked like this
To remove the gaps durations, I used the legend to de-colored them, remove the boarders and remove them.
Now, I would like to plot the same gantt chart in Matlab using the following command:
barh(Positions,Gap_Duration,'stacked');
where:
Positions=[1,2,3,4];
Gap_Duration=[0,2,5,3,5,3;
3,5,3,5,3,4;
9,3,0,0,12,2;
13,2,2,2,8,3];
However, I want to change the color for every job duration (every even column at the Gap_Duration Matrix) and No-Color & No-Boarder for every gap duration (every odd column at the Gap_Duration Matrix).
Note: this only a simple example, I am dealing with a Gap_Duration Matrix with a size of (60,55*2),
60 positions and 55 jobs with their 55 gaps. where each job should have its own color or at least every 8-10 jobs have different color.
I already did the code for obtaining the Gap_Duration Matrix.
Thanks in advance.

답변 (2개)

Jos (10584)
Jos (10584) 2017년 12월 8일
편집: KSSV 2024년 8월 1일
Use graphic handles to manipulate the graph:
Positions=[1,2,3,4];
Gap_Duration=[0,2,5,3,5,3;
3,5,3,5,3,4;
9,3,0,0,12,2;
13,2,2,2,8,3];
H = barh(Positions,Gap_Duration,'stacked') ;
set(H([1 3 5]),'Visible','off')
  댓글 수: 2
Md. Kawsar Ahmed Asif
Md. Kawsar Ahmed Asif 2018년 5월 13일
Hello Jos,
I don't understand the following command. Could you explain me?
" set(H([1 3 5]),'Visible','off') "
Thanks In Advance ... :)
Jos (10584)
Jos (10584) 2018년 5월 14일
Whenever Matlab plots something it creates a handle to the plotted object. You can manipulate these objects by setting its properties using the handles. In the example above, H is a array of handles to bar elements (see the documentation of barh). The command sets the property "visible" to off for three of them.

댓글을 달려면 로그인하십시오.


Alexis Wang
Alexis Wang 2022년 8월 30일
If it helps, I just published a custom Gantt chart for anyone to use and download on File Exchange here: https://www.mathworks.com/matlabcentral/fileexchange/116970-gantt-chart?s_tid=srchtitle. If you have any questions or feedback, feel free to let me know!

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by