-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirty-plot-same-axes.py
executable file
·56 lines (38 loc) · 1.21 KB
/
dirty-plot-same-axes.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python2
import matplotlib.pyplot as plt
import numpy as np
import re
import itertools
from collections import OrderedDict
from sys import argv, exit
MARKERS = ['.', '>', '<', '*', 'v', '^', 'D', 'X', 'P', 'p', 's']
data = OrderedDict()
mark = []
for arg in argv[1:]:
label = arg
filename = arg
if ":" in arg:
label, filename = arg.split(":")
data[label] = []
with open(filename, 'r') as f:
for line in f.readlines():
try:
val = float(line.strip().replace(',', ''))
data[label].append(val)
except ValueError:
print("bad float: %s" % line)
if line[0] == '=':
mark.append(len(data[label]))
fig, ax = plt.subplots()
markers = itertools.cycle(MARKERS)
handles = []
for i, (label, ys) in enumerate(data.items()):
xs = np.arange(len(ys))
h_plot, = ax.plot(xs, ys, label = label, linestyle = 'None', marker = markers.next(), color = np.random.rand(3,))
handles.append(h_plot)
for m in mark:
plt.axvline(x=m, color = 'red')
#ax.set_ylim((0,100000))
plt.legend(handles=handles)
#fig.tight_layout() # otherwise the right y-label is slightly clipped
plt.show()