-
Notifications
You must be signed in to change notification settings - Fork 2
/
plottangling.m
71 lines (60 loc) · 2 KB
/
plottangling.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
61
62
63
64
65
66
67
68
69
function plottangling(project,versions, locs, filenums, option)
% given the version information of project, plot its tangling graph
% option:1 version
% option:2 loc
% option:3 filenum
% store average tangling for each version of given project
sizeproj = size(versions,1);
avg_tangling = zeros(3,sizeproj);
for i=1:sizeproj
load(fullfile(project,'mat',sprintf('%s%s',versions{i},'-tangling.mat'))); %load tangling
load(fullfile(project,'mat',sprintf('%s%s',versions{i},'-docprob.mat'))) ; %load doc prob
%avg_tangling(1,i) = sum(tangling.*docprob);
avg_tangling(1,i) = sum(tangling)/size(tangling,2);
avg_tangling(2,i) = locs(i,1);
avg_tangling(3,i) = filenums(i,1);
end
%y range
len = max (avg_tangling(1,:))- min(avg_tangling(1,:));
y1 = min(avg_tangling(1,:))-0.1*len;
y2 = max(avg_tangling(1,:))+0.1*len;
% version
if(option==1)
savefigpath = fullfile(project,'fig','avgtangling-version');
x1 = 1-0.05*(sizeproj-1);
x2 = sizeproj + 0.05*(sizeproj-1);
for i=1: sizeproj
plot(i, avg_tangling(1,i),'r.','MarkerSize',15);
hold on;
end
xlabel ('version');
%loc
elseif(option==2)
savefigpath = fullfile(project,'fig','tangling-loc');
lencode = max(locs) - min(locs);
x1 =min(locs) - 0.05*lencode;
x2= max(locs) + 0.05*lencode;
for i=1: sizeproj
plot(locs(i,1), avg_tangling(1,i),'r.','MarkerSize',15);
hold on;
end
xlabel ('LOC');
elseif(option==3)
savefigpath = fullfile(project,'fig','avgtangling-filenum');
lenfile = max(filenums) - min(filenums);
x1 =min(filenums) - 0.05*lenfile;
x2= max(filenums) + 0.05*lenfile;
for i=1: sizeproj
plot(filenums(i,1), avg_tangling(1,i),'r.','MarkerSize',15);
hold on;
end
xlabel ('file number');
else
disp('check option');
end
ylabel ('average tangling');
title(project);
axis([x1,x2,y1,y2]);
saveas(gcf,savefigpath,'emf');
clf;
save(fullfile(project,'mat','avgtangling.mat'),'avg_tangling');