setEdgeLineStyle (networkvisualizer)

index

setEdgeLineStyle (networkvisualizer)

Set the line style of edges for a given networkvisualizer object.

Syntax

net = setEdgeLineStyle(net, style)
net = setEdgeLineStyle(net, values)
net = setEdgeLineStyle(net, values, categories)
net = setEdgeLineStyle(net, values, categories, classname)

Arguments

Description

Examples

Setting the line style of all edges

rng(1, 'twister'); % For reproducibility
% Generate a random network with 50 nodes and 100 edges
nNode = 8;
prepareRandomNetwork = @(n1, n2, numedges) logical(sparse(...
   randi([1 n1], numedges, 1), randi([1 n2], numedges, 1), 1, n1, n2));
W = prepareRandomNetwork(nNode, nNode, 100);
net = networkvisualizer(W);
net.setEdgeColors([0 0 0]);
net.setEdgeLineWidth(2);
% Set the edge line style as dotted ':'
net.setEdgeLineStyle(':');
% Plot the network
plot(net);

which produces:

Updating line style of edges using classes

size_values = randi([1 2], nNode, 1);
size_cats = {'small', 'big'};
net.addNodeClass(size_cats(size_values), 'NodeSize');
net.setNodeSizes({10, 20}, {'small', 'big'}, 'NodeSize');
% Create an edge class based on 'NodeSize' categories
net.createEdgeClass('EdgeCategory', 'NodeSize')
% Set the style of edges between small nodes to '--' and big nodes to '-'
net = setEdgeLineStyle(net, {'--', '-'}, {'small-small', 'big-big'}, 'EdgeCategory');
plot(net);

which produces:

See Also

networkvisualizer, addNodeClass, addEdgeClass, createEdgeClass, setNodeSizes, setEdgeColors, setEdgeLineWidth