-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
87 lines (68 loc) · 1.81 KB
/
plot.py
File metadata and controls
87 lines (68 loc) · 1.81 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
import plotly.plotly as py
import plotly.graph_objs as go
nIntervals = 20
nAttribute = 14
intervals = []
posValue = []
negValue = []
minValue = -100
maxValue = 20
step = float((maxValue-minValue)/nIntervals)
start = True
globalMax = 0
globalMin = 100
for x in range(0, nIntervals):
intervals.append(minValue + x*step)
posValue.append(0)
negValue.append(0)
f = open('Datos', 'r')
for line in f:
a = line.split(",")
if (a[nAttribute] == "?"):
continue
if (start):
#print (a[nAttribute])
#print float(a[nAttribute])
globalMax = float(a[nAttribute])
globalMin = float(a[nAttribute])
start = False
if (a[nAttribute] < globalMin):
globalMin = a[nAttribute]
if (a[nAttribute] > globalMax):
globalMax = a[nAttribute]
for x in range(0, nIntervals):
#print float( a[nAttribute] )
if ( ( float( a[nAttribute] ) >= minValue + x*step ) and \
( float( a[nAttribute] ) < minValue + (x + 1)*step ) ):
if (a[15] == "+\n"):
posValue[x] += 1
if (a[15] == "-\n"):
negValue[x] += 1
break
print "MIN: " + str(globalMin) + " | MAX: " + str(globalMax)
#print negValue
#print posValue
f.closed
positiveBar = go.Bar(
x = intervals,
y = posValue,
name = 'Positivo'
)
negativeBar = go.Bar(
x = intervals,
y = negValue,
name = 'Negativo'
)
data = [positiveBar, negativeBar]
layout = go.Layout(
title = "Atributo #" + str(nAttribute + 1),
yaxis=dict(
title='Numero de Casos',
),
xaxis=dict(
title='Valor',
),
barmode = 'group'
)
fig = go.Figure(data=data, layout=layout)
plot_url = py.plot(fig, filename='ESTE')