Using plot to generate a graph of a directed graph, how can i turn off the color of some lines
조회 수: 5 (최근 30일)
이전 댓글 표시
I am plotting digraphs of Markov matrices. I wish to use line thickness as a visual indicator of the strength or flow of the link on each edge. To do this, I must provide a non-zero thickness value for each line. This means that even lines which are not drawn must be dummied with a very tiny value in order for the links to have thicknesses proportional to the transition coefficient. I can live with that, but find I have drawn lines that cannot exist (We cannot normally go from death to a state of health). How can I change the color of these fake lines to white, so they cannot be seen? I am using the functions: tp4=TP*TP*TP*TP %raise transition probabilities to fourth power of a 6 x 6 transition matrix from health to death. tpp=tp4' %transpose to allow taking the columns wt=tpp(:) %create a vector from column values wt4=wt(1:31)*20+.01 %blow up the number to get a visual line width and add a fudge factor to adjust the natural zeros. names={'No Disability' 'Mild Disability' 'ADL Only' 'CI Only' 'ADL & CI' 'Dead'} gr4=digraph(tp4, names) plot(gr4,'layout','circle','LineWidth',wt4 )
Now--to wipe out the zero lines I have drawn?
댓글 수: 0
답변 (1개)
Christine Tobler
2018년 2월 21일
You can set the LineStyle property of these edges to 'none', which will make them not display.
p = plot(gr4,'layout','circle','LineWidth',wt4);
highlight(p, wt4==0.01, 'LineStyle', 'none');
댓글 수: 2
Kelly Kearney
2018년 2월 21일
Minor syntax error in the suggested solution... to highlight edges, you need to provide the 'edges' input:
highlight(zz,'edges', LineW==.01,'LineStyle','none')
참고 항목
카테고리
Help Center 및 File Exchange에서 Directed Graphs에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!