How to add a new graph with keeping the old one plotted?

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 22 Gen 2017
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.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by