Visualizing flow through graph networks
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Steven Lord
2019-11-12
Set the NodeCData property of the GraphPlot object.
p.NodeCData = G.Nodes.Value;
colorbar % to see the mapping between value and color
3 个评论
Steven Lord
2019-11-12
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!