forked from ivanbrugere/matlab-networks-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathel2geom.m
executable file
·57 lines (50 loc) · 1.57 KB
/
el2geom.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
%##################################################################
% Plot a graph for which nodes have given coordinates. Apply color
% scheme and thicker lines if edges have varying weights.
%
% INPUTS: extended edge list el[i,:]=[n1 n2 m x1 y1 x2 y2]
% OUTPUTS: geometry plot, higher-weight links are thicker and lighter in color
%
% Note 1: m - edge weight; (x1,y1) are the Euclidean coordinates of n1, (x2,y2) - n2
% Note 2: Easy to change colors and corresponding edge weight coloring
%
% GB: last updated: December 8, 2012
%##################################################################
function []=el2geom(el)
set(gcf,'Color',[1 1 1])
map=colormap('winter'); % ============ CHANGE COLORMAP HERE
for i=1:size(el,1)
% plot line between two nodes
x1=el(i,4); y1=el(i,5);
x2=el(i,6); y2=el(i,7);
% edge weights ============== CHANGE COLORMAP-LINE THICKNESS SCALE HERE
if el(i,3)<2
color=map(8,:);
linew=1;
elseif el(i,3)>=2 & el(i,3)<3
color=map(2*8,:);
linew=2;
elseif el(i,3)>=3 & el(i,3)<4
color=map(3*8,:);
linew=3;
elseif el(i,3)>=4 & el(i,3)<5
color=map(4*8,:);
linew=4;
elseif el(i,3)>=5 & el(i,3)<6
color=map(5*8,:);
linew=5;
elseif el(i,3)>=6 & el(i,3)<7
color=map(6*8,:);
linew=6;
elseif el(i,3)>=7 & el(i,3)<8
color=map(7*8,:);
linew=7;
elseif el(i,3)>=8
color=map(8*8,:);
linew=8;
end
line([x1 x2],[y1 y2],'LineWidth',linew,'Color',color)
hold off; hold on;
end
axis equal
axis off