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

2 Ansichten (letzte 30 Tage)
Ismaeel
Ismaeel am 22 Jan. 2017
Kommentiert: Ismaeel am 22 Jan. 2017
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Jan. 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.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by