Visualizing flow through graph networks
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I've the following graph.
tail = 1:9;
head = 2:10;
G = graph(tail,head);
data = 1:10;
G.Nodes.Value = data';
p = plot(G)
p.Marker = 's';
p.MarkerSize = 7;
From the examples shown here, I could understand how linewidths of edges can be adjusted based edge weights. However,
in my example I have values assigned to nodes. I would like to change the color of nodes based on values stored in data.
Any suggestion on how this can be done?
0 Kommentare
Antworten (1)
Steven Lord
am 12 Nov. 2019
Set the NodeCData property of the GraphPlot object.
p.NodeCData = G.Nodes.Value;
colorbar % to see the mapping between value and color
3 Kommentare
Steven Lord
am 12 Nov. 2019
The corresponding property for edges is EdgeCData.
When you display p, you can see a list of some of the properties of the GraphPlot that you can query or change. There's also a link you can click to see more properties.
If you want more information about the values each of those properties can take and what each property means, see this documentation page. If you're using an older release you probably want to reference the properties link on the documentation page for GraphPlot instead of the online documentation for the current release, since we have added properties to the GraphPlot object in some recent releases.
doc GraphPlot
Siehe auch
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!