Blame view

MODFIRE-Prototype/plotPareto.py 1.33 KB
3f79bcaa   Eduardo Eloy   added tools to v...
1
2
3
4
5
6
7
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")
29a181fe   Eduardo Eloy   paretoworking and...
8
#lines=sorted(list(map(str, f.readlines())))
3f79bcaa   Eduardo Eloy   added tools to v...
9

df0e5c82   Eduardo Eloy   added region para...
10
f2 =open("nonParetoWS.csv","r")
29a181fe   Eduardo Eloy   paretoworking and...
11
12
13
#lines2 = sorted(list(map(str, f2.readlines())))

lines=f.readlines()
3f79bcaa   Eduardo Eloy   added tools to v...
14
15
lines2 = f2.readlines()

29a181fe   Eduardo Eloy   paretoworking and...
16
17


3f79bcaa   Eduardo Eloy   added tools to v...
18
19
20
21
22
23
24
25
x = []
y = []
lst = []
scatterx = []
scattery = []

for i in lines:
	result = i.split(',')
29a181fe   Eduardo Eloy   paretoworking and...
26
27
28
	x.append(int(result[0]))
	y.append(int(result[1]))
	lst.append([int(result[0]),int(result[1])])
3f79bcaa   Eduardo Eloy   added tools to v...
29
30
31
f.close()


df0e5c82   Eduardo Eloy   added region para...
32
lim = 0
3f79bcaa   Eduardo Eloy   added tools to v...
33
for j in lines2:
df0e5c82   Eduardo Eloy   added region para...
34
35
36
	lim = lim + 1
	#if(lim == 200):
		#break
3f79bcaa   Eduardo Eloy   added tools to v...
37
	result = j.split(',')
29a181fe   Eduardo Eloy   paretoworking and...
38
	if([int(result[0]), [int(result[1])]] in lst):
3f79bcaa   Eduardo Eloy   added tools to v...
39
40
		continue
	else:
29a181fe   Eduardo Eloy   paretoworking and...
41
42
		scatterx.append(int(result[0]))
		scattery.append(int(result[1]))
3f79bcaa   Eduardo Eloy   added tools to v...
43
44
45
46
47
48
49
50
51
52
53

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))

3f79bcaa   Eduardo Eloy   added tools to v...
54
55

plt.scatter(scatterx, scattery, marker = 'x', color = 'r', label = "non-pareto")
29a181fe   Eduardo Eloy   paretoworking and...
56
plt.scatter(x, y, label = 'pareto frontier')
df0e5c82   Eduardo Eloy   added region para...
57
58
#plt.plot(x, y)
#plt.plot(x, y, linestyle='--', marker = 'o', color = 'b', label = 'pareto frontier')
3f79bcaa   Eduardo Eloy   added tools to v...
59

3f79bcaa   Eduardo Eloy   added tools to v...
60

df0e5c82   Eduardo Eloy   added region para...
61
62
63
#plt.xlim([xmin, xmax])
#plt.ylim([ymin, ymax])

29a181fe   Eduardo Eloy   paretoworking and...
64
65
#plt.xticks(x[::10],  rotation='vertical')
#plt.yticks(y[::10],  rotation='horizontal')
3f79bcaa   Eduardo Eloy   added tools to v...
66

3f79bcaa   Eduardo Eloy   added tools to v...
67
68
69
70


plt.legend()
plt.show()