소스 검색

Make histograms relative and rename the degree plots' out files

dustin.born 6 년 전
부모
커밋
2d1dd568aa
1개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 11 11
      code/ID2TLib/Statistics.py

+ 11 - 11
code/ID2TLib/Statistics.py

@@ -1060,7 +1060,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_in_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-In Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
 
@@ -1113,7 +1113,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_out_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-Out Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
 
@@ -1166,7 +1166,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_overall_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-Overall Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
             return out
@@ -1363,7 +1363,7 @@ class Statistics:
 
             # set additional plot parameters
             plt.title(title)
-            plt.ylabel("Number of connections")
+            plt.ylabel("Relative frequency of connections")
             plt.xlabel(label)
             width = 0.5
             plt.grid(True)
@@ -1374,11 +1374,11 @@ class Statistics:
             for i in range(0, 11):
                 bins.append(i * max_val/10)
 
-            # comment out and set weights to normalize
-            # weights = numpy.ones_like(result)/float(len(result))
+            # set weights normalize histogram
+            weights = numpy.ones_like(result)/float(len(result))
 
             # plot the above data, first use plain numbers as graphy to maintain sorting
-            plt.hist(result, bins=bins, color='red', edgecolor='red', align="mid", rwidth=0.5)
+            plt.hist(result, bins=bins, weights=weights, color='red', edgecolor='red', align="mid", rwidth=0.5)
             plt.xticks(bins)
 
             # save created figure
@@ -1409,7 +1409,7 @@ class Statistics:
 
             # set additional plot parameters
             plt.title(title)
-            plt.ylabel("Number of IPs")
+            plt.ylabel("Relative frequency of IPs")
             plt.xlabel(label)
             width = 0.5
             plt.grid(True)
@@ -1420,11 +1420,11 @@ class Statistics:
             for i in range(0, 11):
                 bins.append(int(i * max_val/10))
 
-            # comment out and set weights to normalize
-            # weights = numpy.ones_like(result)/float(len(result))
+            # set weights normalize histogram
+            weights = numpy.ones_like(result)/float(len(result))
 
             # plot the above data, first use plain numbers as graphy to maintain sorting
-            plt.hist(result, bins=bins, color='red', edgecolor='red', align="mid", rwidth=0.5)
+            plt.hist(result, bins=bins, weights=weights, color='red', edgecolor='red', align="mid", rwidth=0.5)
             plt.xticks(bins)
 
             # save created figure