-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plot_Hierarchy.m
60 lines (49 loc) · 1.63 KB
/
Plot_Hierarchy.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
58
59
60
% Plot clustering coefficient in function of degree C(k) vs k
%
% Jesús Pérez-Ortega
% Modified Jan 2019
function [slope,R2,intercept,links,clocal] = Plot_Hierarchy(adjacency,name,save)
switch(nargin)
case 1
name = '';
save = false;
case 2
save= false;
end
% Number of cells
N=length(adjacency);
if ~N
links=0;
clocal=0;
return;
end
links=sum(adjacency)';
clocal=clustering_coef_bu(adjacency);
l=links;
c=clocal;
% delete zeros clustering coefficients
x=links(clocal>0);
y=clocal(clocal>0);
Set_Figure([name ' - Hierarchy'],[0 0 600 200]);
[slope, intercept, R2] = Fit_Power_Law(x,y);
xfit=min(x):(max(x)-min(x))/100:max(x);
yfit=intercept*xfit.^slope;
% linear plot
Set_Axes(['Axes - C(k) lineal' name],[0 0 0.5 1]); hold on
plot(xfit,yfit,'k','linewidth',2,'markersize',10); hold on
plot(l,c,'or','linewidth',2,'markersize',10)
xlabel('k'); ylabel('C(k)')
title('Local Clustering Coeficient C(k)')
% Write the coefficients
text(max(x)/2,max(y)*0.8,['\alpha=' num2str(-slope,'%0.1f')],'FontSize',14,'FontWeight','bold')
text(max(x)/2,max(y)*0.6,['R^2=' num2str(R2,'%0.3f')],'FontSize',14,'FontWeight','bold')
% loglog plot
Set_Axes(['Axes - C(k) loglog' name],[0.5 0 0.5 1])
loglog(xfit,yfit,'k','linewidth',2,'markersize',10); hold on
loglog(l,c,'or','linewidth',2,'markersize',10)
xlabel('k'), ylabel('C(k)')
title('Local Clustering Coeficient C(k)')
if(save)
Save_Figure([name ' - Hierarchy'])
end
end