How to add a new graph with keeping the old one plotted?
2 次查看(过去 30 天)
显示 更早的评论
I have a 14-node graph with a connectivity matrix A:
A= [ 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0; -1 0 -1 -1 -1 0 0 0 0 0 0 0 0 0; 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0; 0 -1 -1 0 -1 0 -1 0 -1 0 0 0 0 0; -1 -1 0 -1 0 -1 0 0 0 0 0 0 0 0; 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 0; 0 0 0 -1 0 0 0 -1 -1 0 0 0 0 0; 0 0 0 0 0 0 -1 0 0 0 0 0 0 0; 0 0 0 -1 0 0 -1 0 0 -1 0 0 0 -1; 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0; 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0; 0 0 0 0 0 -1 0 0 0 0 0 0 -1 0; 0 0 0 0 0 -1 0 0 0 0 0 -1 0 -1; 0 0 0 0 0 0 0 0 -1 0 0 0 -1 0;]
I have plotted it using the code:
>> G = graph(A~=0);
>> h=plot(G,'NodeColor','red','MarkerSize',15);
I want also to plot some certain nodes (only nodes without lines) with different color and smaller size so that I can see both, let's say B is the vector that contains the node locations to be plotted:
B = [5 10]
This is the code I used it:
>> highlight(h, B,'NodeColor','y','MarkerSize',10);
However, it erases the previous corresponding nodes plotted in A. Any idea so that I can keep both plotted, the red and yellow at nodes 5 & 10? Thanks in advance
0 个评论
采纳的回答
Walter Roberson
2017-1-22
You can extract h.XData and h.YData and index into those to get the X and Y locations of the points you want to highly. Then you can scatter() to those locations.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!