How to highlight with multiple colors?
Show older comments
I would like to plot a graph and highlight edges with multiple colors, sometimes the same edge. If I use the highlight(h, G, ...) command it seems to overwrite the previous highlight command, even if I use hold on. Below is an illustrative example, the grah is a triangle on 1, 2, 3 and I wish to highlight edge 12 and 23 with 10 different colors in the hue scale, each with decreasing width. I added a pause command so the steps are visible and bunch of hold on's to see if any of them gives the desired result. But unfortunately the new highligh always overwrites the previous. I've tried additionally to create multiple edges but the highlight command colors all of them.
G = graph([1, 2, 1], [2, 3, 3]);
H = graph([1, 2],[2, 3]);
h = plot(G);
hold on
for I=1:10
hold on
highlight(h, H, 'EdgeColor', hsv2rgb([I/10, 1, 1]), 'LineWidth', 11-I);
hold on
pause(0.5);
end
hold off
Accepted Answer
More Answers (0)
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!