-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.py
144 lines (117 loc) · 4.49 KB
/
plotter.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
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
import csv
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
k = 0
plot = "times"
if plot == "scatter":
dataX = []
dataY = []
dataZ = []
trueColors = []
kmColors = []
confrontColors = []
area = []
# row_count = sum(1 for row in csv.reader( open('newDataset.csv') ) )
#
# with open('newDataset.csv') as File:
# i = 0
# reader = csv.reader(File, delimiter=',', quotechar=',',
# quoting=csv.QUOTE_MINIMAL)
# for row in reader:
# if i < row_count:
# dataX.append(round(float(row[0]),3))
# dataY.append(round(float(row[1]),3))
# trueColors.append(float(row[2]))
# kmColors.append(not float(row[3])) if float(float(row[3]) != 2) else kmColors.append(float(row[3]))
# confrontColors.append('#8e8e8e') if trueColors[i] == kmColors[i] else confrontColors.append('#ff0000')
# area.append(2)
# i=i+1
#
row_count = sum(1 for row in csv.reader( open('newDataset3D.csv') ) )
with open('newDataset3D.csv') as File:
i = 0
reader = csv.reader(File, delimiter=',', quotechar=',',
quoting=csv.QUOTE_MINIMAL)
for row in reader:
if i < row_count:
dataX.append(round(float(row[0]),3))
dataY.append(round(float(row[1]),3))
dataZ.append(round(float(row[2]),3))
trueColors.append(float(row[3]))
# kmColors.append(not float(row[3])) if float(float(row[3]) != 2) else kmColors.append(float(row[3]))
kmColors.append(float(row[4]))
area.append(5)
i=i+1
print(len(dataX))
x = dataX
y = dataY
z = dataZ
# fig, (ax1, ax2, ax3) = plt.subplots(1,3)
# fig.suptitle('Horizontally stacked subplots')
# ax1.scatter(x, y, s=area, c=trueColors, alpha=0.5)
# ax2.scatter(x, y, s=area, c=kmColors, alpha=0.5)
# ax3.scatter(x, y, s=area, c=confrontColors, alpha=0.5)
fig = pyplot.figure()
ax2 = Axes3D(fig)
ax2.scatter(x, y, z, s=area, c=kmColors, alpha=0.5)
elif plot == "times":
dataX = []
# dataYOMP = []
# dataYCPP = []
dataYCUDA1 = []
dataYCUDA2 = []
# dataYCUDA3 = []
# with open('omp.csv') as File:
# reader = csv.reader(File, delimiter=',', quotechar=',',
# quoting=csv.QUOTE_MINIMAL)
# for row in reader:
# dataX.append(row[0])
# dataYOMP.append(round(float(row[1]),6))
# with open('cpp.csv') as File:
# reader = csv.reader(File, delimiter=',', quotechar=',',
# quoting=csv.QUOTE_MINIMAL)
# for row in reader:
# dataYCPP.append(round(float(row[1]),6))
with open('cuda.csv') as File:
reader = csv.reader(File, delimiter=',', quotechar=',',
quoting=csv.QUOTE_MINIMAL)
for row in reader:
dataX.append(row[0])
dataYCUDA1.append(round(float(row[1]),6))
with open('cudaSlow.csv') as File:
reader = csv.reader(File, delimiter=',', quotechar=',',
quoting=csv.QUOTE_MINIMAL)
for row in reader:
dataYCUDA2.append(round(float(row[1]),6))
# with open('cuda3.csv') as File:
# reader = csv.reader(File, delimiter=',', quotechar=',',
# quoting=csv.QUOTE_MINIMAL)
# for row in reader:
# dataYCUDA3.append(round(float(row[1]),6))
fig, ax = plt.subplots()
# ax.plot(dataX, dataYCPP, '-b', label='CPP')
# ax.plot(dataX, dataYOMP, '-r', label='OMP')
ax.plot(dataX, dataYCUDA1, '-y', label='CUDA')
ax.plot(dataX, dataYCUDA2, '-g', label='CUDA_SLOW')
# ax.plot(dataX, dataYCUDA3, '-p', label='CUDA3')
plt.xlabel('#points')
plt.ylabel('execution time (s)')
leg = ax.legend()
for i in range(3):
dataX.pop()
# dataYOMP.pop()
# dataYCPP.pop()
dataYCUDA1.pop()
dataYCUDA2.pop()
fig, ax = plt.subplots()
# ax.plot(dataX, dataYCPP, '-b', label='CPP')
# ax.plot(dataX, dataYOMP, '-r', label='OMP')
ax.plot(dataX, dataYCUDA1, '-y', label='CUDA1')
ax.plot(dataX, dataYCUDA2, '-g', label='CUDA2')
# ax.plot(dataX, dataYCUDA3, '-p', label='CUDA3')
plt.xlabel('#points')
plt.ylabel('execution time (s)')
leg = ax.legend()
plt.show()