From c493035e37fa0071e2ca5f973ccf895d16adce09 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Mon, 6 Jul 2015 15:07:13 +0100 Subject: Added script for plotting times. --- scripts/plottimes.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/plottimes.py diff --git a/scripts/plottimes.py b/scripts/plottimes.py new file mode 100644 index 0000000..8c5b433 --- /dev/null +++ b/scripts/plottimes.py @@ -0,0 +1,48 @@ +import sys +import numpy as np +import matplotlib.pyplot as plt +import json + +MISSING_VALUE = -100 + +def fill(v): + i = 0 + while i < len(v)-1: + if v[i][0]+1 != v[i+1][0]: + v = v[:i+1] + [(v[i][0]+1, None)] + v[i+1:] + i += 1 + return v + + +def get_list_from_data(data): + return sorted([(int(x), float(data[x]['totalTime'])) for x in [y for y in data]]) + +def main(input_filename_1, input_filename_2): + + with open(input_filename_1, 'r') as f: + data_1 = json.load(f) + + with open(input_filename_2, 'r') as f: + data_2 = json.load(f) + + max_value = max([int(x) for x in data_1] + [int(x) for x in data_2]) + + times_1 = fill(get_list_from_data(data_1)) + times_2 = fill(get_list_from_data(data_2)) + + x = np.array(zip(*times_1)[0]) + y_1 = np.array(zip(*times_1)[1]) + y_2 = np.array(zip(*times_2)[1]) + colors_1 = '#eeefff' + colors_2 = '#11ee55' + + # plt.axvline([i for i in range(max_value)], color='k', linestyle='solid') + plt.scatter(x, y_1, c=colors_1, marker=',', s=50) + plt.scatter(x, y_2, c=colors_2, marker='v', s=50) + plt.xticks(np.arange(1, 21, 1.0)) + plt.grid() + plt.show() + + +if __name__ == '__main__': + main(sys.argv[1], sys.argv[2]) \ No newline at end of file -- cgit v1.2.3