필터 지우기
필터 지우기

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?

답변 (1개)

Christine Tobler
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
Lawrence Nitz
Lawrence Nitz 2018년 2월 21일
Thanks for the assistance: Using a clean copy of this code:
% Take third power and Fake the missing edges PF3=primary * primary *primary+.01 LineW=PF3(:)*10 q=digraph(PF3) zz=plot(q, "LineWidth",LineW) labelnode(zz,[ 1 2 3 4 5 6],{'No Disability' 'Mild Disability' 'HIPAA ADL' 'HIPAA CI' ')HIPAA ADL & CI' 'Dead'}) %This works up to this point, then generates this error
highlight(zz,LineW==.01,'LineStyle','none') Then gives this error:
Error using matlab.graphics.chart.primitive.GraphPlot/highlight Expect NODES input to be a numeric vector, a character vector, a cell vector of character vectors, or a logical vector of length equal to the number of nodes.
Error in Test_line_hiding (line 25) highlight(zz,LineW==.01,'LineStyle','none')
I presume the equivalency test on the line weight should work on the whole vector. My inexperience may lead me astray.
Kelly Kearney
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 CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by