-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp_radar.py
More file actions
155 lines (119 loc) · 3.67 KB
/
comp_radar.py
File metadata and controls
155 lines (119 loc) · 3.67 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Libraries
import matplotlib.pyplot as plt
import matplotlib.dates as mpd
import numpy as np
from math import pi
import datetime as dt
from dateutil.parser import parse
import sys # for command line args
import re
# for use with PRT.py proposal review tool
#
# to use, open PRT.py ProjectDir/
# click "Progress Graph" button
# run this program.
#
##################### "Radar" style radial status plot
# get data
#print 'Number of arguments:', len(sys.argv), 'arguments.'
#print 'Argument List:', str(sys.argv)
if(len(sys.argv) != 2):
print "Usage: python comp_radar.py <projectfoldername>"
print " please add a project folder name to the command line."
quit()
else:
proj_name = str(sys.argv[1])
# delete trailing '\' if present
proj_name = re.sub(r'\/$','', proj_name)
f= open(proj_name + '/rev_prog.csv','r')
fc = [] # field completion count
cc = [] # character count
id = []
for line in f:
a,b,c,d = line.split(',')
c = c.strip()
b = b.strip()
fc.append(float(b))
cc.append(float(c))
id.append(a)
N = len(cc)
#for i in range(N):
#print '{} {}'.format(fc[i],cc[i])
# We are going to plot the first line of the data frame.
# But we need to repeat the first value to close the circular graph:
#values=df.loc[0].drop('group').values.flatten().tolist()
#values += values[:1]
#values
fc.append(fc[0])
cc.append(cc[0])
# What will be the angle of each axis in the plot? (we divide the plot / number of variable)
angles = [n / float(N) * 2 * pi for n in range(N)]
angles += angles[:1]
# Initialize the spider plot
#fig = plt.figure(figsize=(8, 6))
fig,ax = plt.subplots(figsize=(15,15), subplot_kw=dict(polar=True))
#fig.figsize = (10,10)
ticks = []
for i in range(N):
ticks.append('`{}'.format(id[i]))
# Draw one axis per variable + add labels labels yet
plt.xticks(angles[:-1], ticks, color='blue', size=16)
## Draw ylabels
#ax.set_rlabel_position(0)
#plt.yticks([10,20,30], ["10","20","30"], color="grey", size=7)
plt.ylim(0,1.00)
# Plot data
ax.plot(angles, fc, 'r', linewidth=1, linestyle='solid')
ax.plot(angles, cc, 'b', linewidth=1, linestyle='solid')
# Fill area
ax.fill(angles, cc, 'b', alpha=0.1)
ax.fill(angles, fc, 'r', alpha=0.1)
plt.title( 'Completion: blue = characters, red = fields',size=24)
##################### Plot progress over time
f= open(proj_name + '/rev_work.csv','r')
dateTimeFormat = '%Y-%m-%d, %H:%M:%S'
day = []
time = []
chars = []
fields = []
char_pct = []
field_pct = []
a,b = f.readline().split(',')
duedate = parse(a+' '+b)
for line in f:
a,b,c,d,e,f = line.split(',')
day.append(parse(a+' '+b))
chars.append(int(c))
fields.append(int(d))
char_pct.append(float(e))
field_pct.append(float(f))
fig,ax = plt.subplots(figsize=(20,8))
#start_dt = day[0]
#end_dt = day[-1]
end_dt = duedate
#print('Plotting due date: ', end_dt.strftime(dateTimeFormat))
start_dt = duedate - dt.timedelta(days=30)
Nxticks = 5
time_inc = (end_dt-start_dt)/Nxticks
xticks = []
#for i in range(Nxticks)
#xticks.append(str(time_inc*i))
#dts = mpd.drange(start_dt,end_dt,time_inc)
#dts = dts[:-1]
#np.append(dts, [end_dt+time_inc])
print('-----')
#print day, chars
ax.xaxis.set_major_formatter(mpd.DateFormatter('%Y-%m-%d'))
ax.xaxis.set_major_locator(mpd.DayLocator(interval=1))
ax.set_ylabel('Total Characters Entered',color='blue',fontsize=14)
ax.plot(day, chars)
ax.set_ylim(0,30000)
ax2=ax.twinx()
ax2.plot(day,field_pct,color='red')
ax2.set_ylabel('Fraction of Fields Entered',color='red',fontsize=14)
ax2.set_ylim(0,1.00)
fig.autofmt_xdate()
#plt.ylim(0,30000)
plt.xlim(start_dt,end_dt)
plt.title('Character count vs time')
plt.show()