-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstat_1.py
More file actions
25 lines (22 loc) · 757 Bytes
/
stat_1.py
File metadata and controls
25 lines (22 loc) · 757 Bytes
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
def calstat():
import matplotlib
import utils
matplotlib.use('Qt4Agg')
from matplotlib import pyplot as plt
vert = hori = 0
with open('movefile.txt', 'r') as in_file:
for line in in_file:
if line[0] == '1':
vert += 1
else:
hori += 1
# Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = 'Vertical Moves', 'Horizontal Moves'
sizes = [vert, hori]
explode = (0, 0.1)
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie chart is drawn as a circle.
plt.show()
calstat()