setNodeLabelColor (networkvisualizer)

index

setNodeLabelColor (networkvisualizer)

Set the node label colors for a networkvisualizer object.

Syntax

net = setNodeLabelColor(net, RGB)
net = setNodeLabelColor(net, values)
net = setNodeLabelColor(net, values, categories)
net = setNodeLabelColor(net, values, categories, classname)

Arguments

Description

Examples

Setting the node labels and coloring them randomly

rng(1, 'twister'); % For reproducibility
W = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0];
labels = {'A', 'B', 'C', 'D', 'E'}';
net = networkvisualizer(W);
net.setNodeLabels(labels);
net.setNodeFontSize(30);
% Set the node label colors randomly to one of default colors
defaultcolors = net.getDefaultColors();
colors = defaultcolors(randi([1 3], length(W), 1), :);
net.setNodeLabelColor(colors);
% Plot the network
plot(net);

which produces:

See Also

networkvisualizer, addNodeClass, setNodeLabels, setNodeFontSize