-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplotBars.py
More file actions
57 lines (50 loc) · 1.53 KB
/
Copy pathplotBars.py
File metadata and controls
57 lines (50 loc) · 1.53 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
from datetime import datetime as time
import plotly.graph_objs as go
import plotly.offline as py
global connection
def plotbars(connection):
ls=[]
overall_count=0
flags=[]
percentages=[]
test=[]
flags_query="select distinct (name) from weird"
connection.DBquery.exec_(flags_query)
while connection.DBquery.next():
flags.append(connection.DBquery.value(0))
test.append(connection.DBquery.value(1))
overall_count_query = "select count (*) from weird "
connection.DBquery.exec_(overall_count_query)
while connection.DBquery.next():
overall_count=(connection.DBquery.value(0))
for i in flags:
qu = "select count (*) from weird where name='%s'"%str(i)
print(qu)
connection.DBquery.exec_(qu)
while connection.DBquery.next():
count=(connection.DBquery.value(0))
ls.append(count)
percentages.append("%s of file"%str(count/overall_count*100))
trace0 = go.Bar(
x=flags,
y=ls,
text=percentages,
marker=dict(
color='rgb(158,202,225)',
line=dict(
color='rgb(8,48,107)',
width=1.5,
)
),
opacity=0.6
)
data = [trace0]
layout = go.Layout(
title='weird flags',
autosize=True
)
now = time.now().strftime('%Y-%m-%d %H:%m:%S')
file = 'BILA-weird-bars-%s.html' % now
fig = go.Figure(data=data, layout=layout)
py.plot(fig, filename=file,auto_open=False)
return file