forked from aakankshaa23/efficiency-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproject_r.py
83 lines (61 loc) · 2.02 KB
/
project_r.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#graph plotting
#data
import os
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import style
'exec(%matplotlib inline)'
import csv
import numpy as np
style.use('ggplot')
fig=plt.figure()
ax1=fig.add_subplot(111,projection='3d')
heading=input("Enter measure")
entries=[]
#month=['january','february','march','april','may','june','july','august','september','october','november','december']
filename=os.path.abspath( os.path.join("data","data1.csv"))
with open(filename,'r') as csvfile:
fields=csvfile.readline().strip().split(',')
print(fields)
test_passed=0
products=0
efficiency=[]
for line in csvfile:
parts=line.strip().split(',')
row=dict()
for i,h in enumerate(fields):
row[h]=parts[i]
if(i==3):
test_passed=float(parts[i])
elif(i==1):
products=float(parts[i])
if (products == 0):
div = 0
else:
div = test_passed / products
efficiency.append(int(div*100))
entries.append(row)
print(efficiency)
fig=plt.figure()
ax1=fig.add_subplot(111,projection='3d')
ypos=[]
for i in range(len(entries)):
ypos.append(float(entries[i]['Cost (in billions)']))
xpos_array=[1,2,3,4,5,6,7,8,9,10,11,12]
ypos_array=np.asarray(ypos).astype(int)
zpos_array=np.zeros(12).astype(int)
dx=np.ones(12)
dy=[2,2,2,2,2,2,2,2,2,2,2,2]
dz=[]
my_xticks=['Jan','Feb','Mar','April','May','June','July','Aug','Sept','Oct','Nov','Dec']
for i in efficiency:
dz.append(int(i))
dz_array=np.asarray(dz).astype(int)
plt.xticks(xpos_array,my_xticks,rotation=90)
for i in range(0,12):
ax1.text(xpos_array[i]-0.5,ypos_array[i]+3,dz_array[i],'%s'%str(dz[i]),size=10)
plt.title=heading
ax1.bar3d(xpos_array,ypos_array,zpos_array,dx,dy,dz_array,color=['red','blue','green','yellow','orange','black','brown','cyan','magenta','pink','blue','green'])
plt.show()
#for e in entries:
#print("{0}month , quality tests passed are{1}".format(e['Month'],e['Quality test passed (in millions)']))