How to customize arrow of directed graph (digraph)
조회 수: 24 (최근 30일)
이전 댓글 표시
I am attempting to plot a weighted directed graph that displays weights via augmenting edge thickness. My (pseduo)code thus far is:
G=digraph(weights);
G.Edges.Weight=weightsVec;
G.Edges.LWidths = 6*G.Edges.Weight/max(G.Edges.Weight);
p=plot(G);
p.LineWidth=G.Edges.LWidths;
p.ArrowSize=15;
This works pretty well, but I find that the increased edge widths covers up arrowheads on some of the edges. An obvious fix would be to use larger arrowheads, but this usually ends up looking terrible if your graph has many connections of varying weights (arrowheads look ridiculously large for weights of smaller magnitute). Another way to fix this would be to change the color of the arrowhead (and not the edge, itself) or change the position of the arrowhead to the end of the edge line. Both options appear to be unavailable for the directed graph object. Does anyone have any workarounds?
P.S. I know that there is an option to use a color scale to display edge weights, but I am trying to avoid this approach.
댓글 수: 0
채택된 답변
Christine Tobler
2018년 12월 17일
Since R2018b, there is a property ArrowPosition which allows the arrowhead to move around along the edge.
There is no way of changing the color of the arrowheads separately from the color of the edge. If you really want this, I'd suggest making two graph plots, one on top of the other, and setting edge LineStyle to 'none' for one (which represents the arrows only), while setting ShowArrows to false for the other (which represents only the edges). At that point, you can choose two different edge colors that will affect either the edge lines or the arrows.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!