plotPareto.py
1.18 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
import numpy as np
import matplotlib.pyplot as plt
#val = input("1:WoodYield/SoilLoss \n 2:WoodYield/RiskPercentile \n 3:SoilLoss/RiskPercentile \n 4:All three
f=open("paretoWS.csv","r")
lines=f.readlines()
f2 =open("nonParetoWS.csv","r")
lines2 = f2.readlines()
x = []
y = []
lst = []
scatterx = []
scattery = []
for i in lines:
result = i.split(',')
x.append(result[0])
y.append(result[1])
lst.append([result[0],result[1]])
f.close()
lim = 0
for j in lines2:
lim = lim + 1
#if(lim == 200):
#break
result = j.split(',')
if([result[0], [result[1]]] in lst):
continue
else:
scatterx.append(result[0])
scattery.append(result[1])
f2.close()
xmin = str(int(min(x)) - 1000)
xmax = str(int(max(x)) + 1000)
ymin = str(int(min(y)) - 1000)
ymax = str(int(max(y)) + 1000)
plt.figure(figsize=(100,100))
plt.scatter(scatterx, scattery, marker = 'x', color = 'r', label = "non-pareto")
plt.scatter(x, y)
#plt.plot(x, y)
#plt.plot(x, y, linestyle='--', marker = 'o', color = 'b', label = 'pareto frontier')
#plt.xlim([xmin, xmax])
#plt.ylim([ymin, ymax])
plt.xticks(x[::10], rotation='vertical')
plt.yticks(y[::10], rotation='horizontal')
plt.margins(0.2)
plt.legend()
plt.show()