plotPareto.py 1.62 KB
import numpy as np
import matplotlib.pyplot as plt
import sys
op = ''

if(int(sys.argv[1]) == 1):
	op = 'WS'
elif(int(sys.argv[1]) == 2):
	op = 'WR'
elif(int(sys.argv[1]) == 3):
	op = 'SR'

#val = input("1:WoodYield/SoilLoss \n 2:WoodYield/RiskPercentile \n 3:SoilLoss/RiskPercentile \n 4:All three

f=open("Paredes"+op+"/pareto"+op+".csv","r")
#lines=sorted(list(map(str, f.readlines())))

f2 =open("Paredes"+op+"/nonPareto"+op+".csv","r")
#lines2 = sorted(list(map(str, f2.readlines())))

lines=f.readlines()
lines2 = f2.readlines()



x = []
y = []
lst = []
scatterx = []
scattery = []

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


lim = 0
for j in lines2:
	lim = lim + 1
	#if(lim == 200):
		#break
	result = j.split(',')
	if([int(result[0]), [int(result[1])]] in lst):
		continue
	else:
		scatterx.append(int(result[0]))
		scattery.append(int(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, label = 'pareto frontier')
plt.xlabel("Wood Yield")
plt.ylabel("Soil Loss")
#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')


#fig8 = plt.figure(figsize=(10,4))
plt.legend()
#plt.show()
plt.savefig('Paredes'+op+'/Map/Pareto',dpi=150)