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

19 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Christine Tobler
Christine Tobler le 6 Fév 2019
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 commentaires
Christine Tobler
Christine Tobler le 13 Fév 2019
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 le 28 Sep 2023
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by