# coding:utf-8
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pandas as pd
MyPareto_path = './data/TestResult/DTLZ2/'
TruePareto_path = './data/TruePareto/'
TruePareto_path = TruePareto_path+'DTLZ2.3D.csv'
NSGAII_PARETO = MyPareto_path+'NSGAII_PARETO.csv'
SMOCDE_PARETO = MyPareto_path+'SMOCDE_PARETO.csv'
MOEAD_PARETO = MyPareto_path+'MOEAD_PARETO.csv'
NSGAII = pd.read_csv(NSGAII_PARETO,nrows =101,header=None)
SMOCDE = pd.read_csv(SMOCDE_PARETO,nrows =101,header=None)
MOEAD = pd.read_csv(MOEAD_PARETO,nrows =101,header=None)
ZDT2 = pd.read_csv(TruePareto_path,header=None)
print("NSGAII:",NSGAII.shape)
print("NSGAIII:",NSGAII.shape)
print("SMOCDE:",SMOCDE.shape)
print("MOEAD:",MOEAD.shape)
print("ZDT1:",ZDT2.shape)
print(NSGAII.dtypes)
print(SMOCDE.dtypes)
print(MOEAD.dtypes)
print(ZDT2.dtypes)
print(NSGAII.head())
y11 = list(NSGAII[0])
y12 = list(NSGAII[1])
y13 = list(NSGAII[2])
y21 = list(SMOCDE[0])
y22 = list(SMOCDE[1])
y23 = list(SMOCDE[2])
y31 = list(MOEAD[0])
y32 = list(MOEAD[1])
y33 = list(MOEAD[2])
y41 = list(ZDT2[0])
y42 =list(ZDT2[1])
y43 =list(ZDT2[2])
ax=plt.subplot(111,projection='3d')
#将数据点分成三部分画,在颜色上有区分度
ax.scatter(y11,y12,y13,c='y',label = 'NSGAII') #绘制数据点
ax.scatter(y21,y22,y23,c='r',label = 'SMOCDE')
ax.scatter(y31,y32,y33,c='b',label = 'MOEA/D')
ax.scatter(y41,y42,y43,c='g',label = 'PARETO')
ax.set_zlabel('f3')
ax.set_ylabel('f2')
ax.set_xlabel('f1')
plt.legend(loc =2)
plt.show()