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!