45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from datetime import datetime
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import json
|
|
|
|
def load_data(path):
|
|
with open(path, 'r') as f:
|
|
return json.load(f)
|
|
|
|
|
|
def main():
|
|
data = load_data('./tmp_plot.json')
|
|
times = []
|
|
avg_in = []
|
|
avg_out = []
|
|
known_in = []
|
|
known_out = []
|
|
number_of_nodes = []
|
|
for k, v in sorted(data.items(), key = lambda kv: kv[0]):
|
|
times.append(datetime.fromtimestamp(float(k)))
|
|
avg_in.append(v['avg_in'])
|
|
avg_out.append(v['avg_out'])
|
|
known_in.append(v['known_in'])
|
|
known_out.append(v['known_out'])
|
|
number_of_nodes.append(v['number_of_nodes'])
|
|
|
|
|
|
fig, ax = plt.subplots()
|
|
ax.plot(times, avg_in, label='Avg. In')
|
|
# ax.plot(times, avg_out, label='Avg. Out')
|
|
ax.plot(times, known_in, label='Known In')
|
|
ax.plot(times, known_out, label='Known Out')
|
|
ax.plot(times, number_of_nodes, label='Number of nodes')
|
|
ax.set_title(f'Average edge count per hour')
|
|
fig.autofmt_xdate()
|
|
fig.legend()
|
|
plt.savefig(f'./tmp_plot.png')
|
|
# print('created sr plot')
|
|
plt.show()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|