-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot.py
executable file
·39 lines (29 loc) · 1001 Bytes
/
plot.py
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
#!/usr/bin/python
import argparse
import matplotlib.pyplot as plt
import numpy as np
def draw(x, y, log_scale):
plt.figure(1)
plt.plot(x, y)
plt.xlabel('Data size')
plt.ylabel('Execution time [s]')
if log_scale:
plt.xscale('log')
plt.yscale('log')
plt.title('Time complexity plot')
plt.grid(True)
plt.show()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Plot data from file')
parser.add_argument('file', help='file with data to plot')
parser.add_argument('--csv', '-c',
help='use csv format (default - space separated)',
action='store_true')
parser.add_argument('--log', '-l', help='use logarithmic scale',
action='store_true')
args = parser.parse_args()
delim = ',' if args.csv else ' '
data = np.genfromtxt(args.file, delimiter=delim)
sizes = data[:, 0]
times = data[:, 1]
draw(sizes, times, args.log)