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!