coloring node and edge of a graph
25 views (last 30 days)
Show older comments
Deepa Maheshvare
on 24 Dec 2018
Answered: madhan ravi
on 24 Dec 2018
I have a graph with values assigned to nodes and edges,
t = 1:4;
h = 2:5;
g = graph(t,h);
plot(g)
g.Edges.value = [10; 20; 20; 100];
g.Nodes.value = [0.3; 0.564; 12; 1; 0.005];
I would like to know whether there is an option of coloring the nodes and edges based on the values.
0 Comments
Accepted Answer
Cris LaPierre
on 24 Dec 2018
1 Comment
Cris LaPierre
on 24 Dec 2018
Edited: Cris LaPierre
on 24 Dec 2018
t = 1:4;
h = 2:5;
g = graph(t,h);
p = plot(g);
g.Edges.value = [10; 20; 20; 100];
g.Nodes.value = [0.3; 0.564; 12; 1; 0.005];
g.Nodes.NodeColors = g.Nodes.value;
g.Edges.EdgeColors = g.Edges.value;
p.NodeCData = g.Nodes.NodeColors;
p.EdgeCData = g.Edges.EdgeColors;
colorbar
More Answers (1)
madhan ravi
on 24 Dec 2018
Easy way create a handle to the graph and just use dot indexing and assign the color for instance red , green .. blabla
0 Comments
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!