Is it possible to set an alpha value for each edge in a GraphPlot?

19 次查看(过去 30 天)
Colours for individual edges can be set.
% For individual edges
highlight(H, edge_idx, 'EdgeColour', [1,0,0]);
% For all edges
H.EdgeColour = % matrix with RGB-values for each edge
Opacity for all edges in the graph can be set, too.
H.EdgeAlpha = 0.01;
Unfortunately I cannot find a way to set alpha values for individual edges. Ideally, there should be a fourth channel in H.EdgeColour to control opacity.
Has anyone found a workaround?

采纳的回答

Christine Tobler
Christine Tobler 2019-2-6
Hi Michael,
We do not provide a way to set EdgeAlpha to be different for each edge. We just didn't expect this to be very useful, thinking it would be hard to read these subtle differences in a graph.
For the special case where you want all edges to either have the same alpha or be completely transparent, you could instead use 'LineStyle', 'none' to make some edges completely invisible (use the highlight method for a simpler way to do this).
If you are looking for something else, could you tell me more about what you are doing? What do the different alpha's represent? Are there only a few different alpha values, or is each one slightly different?
  3 个评论
Christine Tobler
Christine Tobler 2019-2-13
The LineStyle property is a scalar by default, this was done to simplify the workflow of setting all edges to the same LineStyle.
The highlight method allows setting the style for a subset of the edges, and will automatically initialize a cell array with one entry for each edge.
p = plot(graph(1, [2 3]));
highlight(p, 1, 3, 'LineStyle', '--')
Daniel Holstein
Daniel Holstein 2023-9-28
I am very surprised that you don't see a use case in assigning alpha to individual edges. As a systems ecologist I often create figures for publications with complex geographic networks. Setting alpha of low weight connections is extremely useful. Right now I get around this with custom code that avoides using digraphs all together, which is unfortunate.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by