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

1 回表示 (過去 30 日間)
Ismaeel
Ismaeel 2017 年 1 月 22 日
コメント済み: Ismaeel 2017 年 1 月 22 日
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.
  1 件のコメント
Ismaeel
Ismaeel 2017 年 1 月 22 日
This is very cool, thank you so much Walter...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-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