Plotting a graph in layered fashion

5 Ansichten (letzte 30 Tage)
Kamal Premaratne
Kamal Premaratne am 24 Sep. 2020
Kommentiert: Kamal Premaratne am 25 Sep. 2020
I am working with a digraph G of the carbon flow between creatures in the Florida Bay. Each creature has been assigned what is referred to as its trophic level which is a numerical value that attempts of quantify its hierarchical level in the food chain. These tropic levels have been entered into the node table as G.Nodes.TrophicLevel. I would like to use the MATLAB command plot(G, 'layout' 'layered') but I want the layers to be determined by the nodes' trophic level. Is there a way to do this?
Thank you very much.

Antworten (1)

Christine Tobler
Christine Tobler am 25 Sep. 2020
Unfortunately, there is currently no way to do this with the 'layered' layout. I'll make a note of your need for this.
For now, you could try to use
plot(G, 'YData', G.Nodes.TrophicLevel, 'XData', rand(numnodes(G), 1))
which will plot the nodes on the correct level, but just give them arbitrary x coordinates.
  1 Kommentar
Kamal Premaratne
Kamal Premaratne am 25 Sep. 2020
Thanks Christine. Yes, I was thinking along the same lines, but I was thinking of picking the same x-coordinate so that the vertices are located along a vertical line. But random x-corrdinates (as you had suggested) might be a better option. I have to check.
And, yes, please make a note of this. It might be agood option to include in an upcoming update.
Thanks again.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by