masterthesis/codes/plot/plot.py

34 lines
863 B
Python
Raw Normal View History

2022-04-01 12:41:55 +02:00
#!/usr/bin/env python3
import matplotlib.pyplot as plt
def read(path):
data = []
with open(path, 'r') as f:
data.extend(map(float, f.readlines()))
return data
ranks = [0.25, 0.5, 0.75]
iterations = 5
for rank in ranks:
for iteration in range(iterations):
count, bins, ignored = plt.hist(read(f'./{rank}_{iteration+1}_sr.txt'), 30)
plt.xlabel('SensorRank')
plt.ylabel('Peers')
s = 's'
e = ''
plt.title(f'SensorRank distribution after {iteration+1} iteration{s if iteration+1 > 1 else e} with initial rank {rank}')
plt.savefig(f'./{rank:.2f}_{iteration+1}_sr.png')
plt.clf()
plt.cla()
# count, bins, ignored = plt.hist(data, 30)
# # plt.show()
# # plt.imsave("", data)
# plt.xlabel('PageRank')
# plt.ylabel('peers')
# plt.title()
# plt.savefig('./0.25_5_sr.png')