Blame view

MODFIRE-Prototype/plotPareto.py 1.18 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=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 = f2.readlines()

x = []
3f79bcaa   Eduardo Eloy   added tools to v...
14
15
y = []
lst = []
29a181fe   Eduardo Eloy   paretoworking and...
16
17
scatterx = []
scattery = []
3f79bcaa   Eduardo Eloy   added tools to v...
18
19
20
21
22
23
24
25

for i in lines:
	result = i.split(',')
	x.append(result[0])
	y.append(result[1])
	lst.append([result[0],result[1]])
f.close()

29a181fe   Eduardo Eloy   paretoworking and...
26
27
28

lim = 0
for j in lines2:
3f79bcaa   Eduardo Eloy   added tools to v...
29
30
31
	lim = lim + 1
	#if(lim == 200):
		#break
df0e5c82   Eduardo Eloy   added region para...
32
	result = j.split(',')
3f79bcaa   Eduardo Eloy   added tools to v...
33
	if([result[0], [result[1]]] in lst):
df0e5c82   Eduardo Eloy   added region para...
34
35
36
		continue
	else:
		scatterx.append(result[0])
3f79bcaa   Eduardo Eloy   added tools to v...
37
		scattery.append(result[1])
29a181fe   Eduardo Eloy   paretoworking and...
38

3f79bcaa   Eduardo Eloy   added tools to v...
39
40
f2.close()

29a181fe   Eduardo Eloy   paretoworking and...
41
42

xmin = str(int(min(x)) - 1000)
3f79bcaa   Eduardo Eloy   added tools to v...
43
44
45
46
47
48
49
50
51
52
53
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')
3f79bcaa   Eduardo Eloy   added tools to v...
54
55


29a181fe   Eduardo Eloy   paretoworking and...
56
#plt.xlim([xmin, xmax])
df0e5c82   Eduardo Eloy   added region para...
57
58
#plt.ylim([ymin, ymax])

3f79bcaa   Eduardo Eloy   added tools to v...
59
plt.xticks(x[::10],  rotation='vertical')
3f79bcaa   Eduardo Eloy   added tools to v...
60
plt.yticks(y[::10],  rotation='horizontal')
df0e5c82   Eduardo Eloy   added region para...
61
62
63


plt.margins(0.2)
29a181fe   Eduardo Eloy   paretoworking and...
64
65


3f79bcaa   Eduardo Eloy   added tools to v...
66
plt.legend()
3f79bcaa   Eduardo Eloy   added tools to v...
67
plt.show()