Visualizing flow through graph networks
조회 수: 3 (최근 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!