forked from errorcodexero/standing_predictor
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.py
More file actions
executable file
·67 lines (52 loc) · 1.49 KB
/
Copy pathplot.py
File metadata and controls
executable file
·67 lines (52 loc) · 1.49 KB
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
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import sys
from argparse import ArgumentParser
def parse_item(s):
return float(s)
def parse_line(s):
return list(map(parse_item,s.split(',')))
def parse_data(data):
return list(map(parse_line,data.splitlines()))
def plot(info,xlabel,ylabel,img_format):
x2=list(map(lambda x: x[0],info))
y2=list(map(lambda x: x[1],info))
#plt.style.use('dark_background')
fig, ax = plt.subplots(figsize=(8,4))
#sys.stderr=tmp
#print ('bbb')
#ax.plot(x2, y2 + 2.5, 'x', markeredgewidth=2)
#print('ccc')
#ax.plot(x, y, linewidth=2.0)
#print('ddd')
#ax.plot(x2, y2 , 'o-', linewidth=2)
#ax.bar(x2, y2 , linewidth=2)
#ax.bar(x2, y2)
ax.stem(x2, y2,basefmt=" ")
plt.ylim(bottom=0)
#print('foo')
#ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
# ylim=(0, 8), yticks=np.arange(1, 8))
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
#probably want this if you have a line but not if you have a bar graph.
#ax.set_xlim(min(x2),max(x2))
#ax.set_ylim(min(y2),max(y2))
#plt.show()
plt.tight_layout()
#plt.savefig("out.svg")
plt.savefig(sys.stdout,format=img_format)
#print('bar')
def main():
a=ArgumentParser()
a.add_argument('--x')
a.add_argument('--y')
a.add_argument('--format',default='png')
args=a.parse_args()
data=sys.stdin.read()
plot(parse_data(data),args.x,args.y,args.format)
if __name__=='__main__':
#print('hello')
#exit(0)
main()