Visualizing flow through graph networks

6 Ansichten (letzte 30 Tage)
Deepa Maheshvare
Deepa Maheshvare am 12 Nov. 2019
Kommentiert: Deepa Maheshvare am 13 Nov. 2019
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?

Antworten (1)

Steven Lord
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
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
Deepa Maheshvare
Deepa Maheshvare am 13 Nov. 2019
Thank you. I think I should be using caxis to set the scale of colorbar
When I try the following,
caxis([0 10])
The color of nodes vary from yellow to blue.
However, I would like to change the scale from gray to black. So, I tried changing the color of node
p.NodeColor = [0 0 0]; %black
I had expected the above would set the color scale to vary from gray to black. This didn't work either.
Any suggestions?

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by