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

采纳的回答

Walter Roberson
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 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by