-
Notifications
You must be signed in to change notification settings - Fork 0
/
comparisonPlotter.py
42 lines (40 loc) · 1.46 KB
/
comparisonPlotter.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
'''
Comparison Plotter
Takes in the three csv files reads them and plots them for comparison.
'''
import csv
import numpy
import matplotlib.pyplot as plot
import matplotlib.patches as mpatches
def extractData(fileName):
rawData = []
f = open(fileName, 'r')
wr = csv.reader(f)
for row in wr:
rawData.append(row)
data = [[float(j[i]) for j in rawData] for i in range(7)]
return data
#extracting data
data1 = []
data1.append(extractData('mopsoConvergenceDataF4Long.csv'))
data1.append(extractData('mosaConvergenceDataF4Long.csv'))
data1.append(extractData('nsga2ConvergenceDataF4Long.csv'))
data1.append(extractData('mopsoConvergenceDataF4NLong.csv'))
data1.append(extractData('mosaConvergenceDataF4NLong.csv'))
data1.append(extractData('nsga2ConvergenceDataF4NLong.csv'))
data1[0][0] = [i*5 for i in data1[0][0]]
#Now begin the plot
col1 = ['r', 'g', 'b']
col1 = col1 + ['r--', 'g--', 'b--']
col2 = ['red', 'green', 'blue']
plotPat = [mpatches.Patch(color=col) for col in col2]
labels = ['Paramerter Space Metric1', 'Paramerter Space Metric2', 'Paramerter Space Metric3', 'Objective Space Metric1', 'Objective Space Metric2', 'Objective Space Metric3']
algLabels = ['MOPSO', 'MOSA', 'NSGA2']
for i in range(3):
plot.subplot(1,3, i + 1)
for j in range(len(data1)):
plot.plot(data1[j][0], data1[j][i+4], col1[j], linewidth = 2)
plot.xlabel('Number of measurements')
plot.ylabel(labels[i+3])
plot.legend(plotPat, algLabels)
plot.show()