Plot graph with different markers

145 views (last 30 days)
Rub Ron
Rub Ron on 9 Feb 2020
Commented: Tormey Reimer on 2 Nov 2021
Hello, I have a graph G lets say with 100 egdes and 40 nodes. The G.nodes are of 3 types stored in a vector type (40x1). How can I plot the graph so that each node adopt the mark corresponding to its type?
h = plot(G,'NodeLabel',mylabel);
mylabel is a 0x1 vector with the labelling of the nodes.
Any references would be really appreciatted.

Accepted Answer

dpb on 9 Feb 2020
See <Marker in Graphplot properties>. Pass an index array to the position of the desired marker type as the 'Marker' property.
mkrs=['o';'x','+']; % the desired markers lookup table
Gtype=[....]; % vector of 1,2,3 defining which marker for each element of G
Property 'NodeLabel' could be used to write some label instead of using the plot marker by the same lookup logic if your desired labels are something different than available plot markers.
  1 Comment
Tormey Reimer
Tormey Reimer on 2 Nov 2021
Just wanted to fix up the syntax on this answer, since I had the exact same question and this appears to be only answer on the internet:
mkrs={'o','x','+'}; % must be cells
Gtype=[....]; % vector referring to cell indices

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!