def plotScatter(self, xList, yList, saveFigPath):
'''
?????? xList ???? yList ????????????
?????? saveFigPath ????
:param xList: ????
:param yList: ????
:param saveFigPath: ????????
:return:
'''
# ????????????
# ??????????? 2
# ???????? 2 ?????
if len(xList[0]) >= 2:
x1List = map(lambda x: x[0], xList)
x2List = map(lambda x: x[1], xList)
else:
# 1 ? 2 ???????? 2 ?
x1List = x2List = map(lambda x: x[0], xList)
# ????
scatterFig= plt.figure(saveFigPath)
# ?????????
colorDict = {-1: 'm', 1: 'r', 2: 'b', 3: 'pink', 4: 'orange'}
# ?????
map(lambda idx: \
plt.scatter(x1List[idx], \
x2List[idx], \
marker='o', \
color=colorDict[yList[idx]], \
label=yList[idx]), \
xrange(len(x1List)))
# ?????????
# ySet = set(yList)
# map(lambda y: \
# plt.legend(str(y), \
# loc='best'), \
# ySet)
# ??????????????
plt.title(saveFigPath)
plt.xlabel(r'$x^1$')
plt.ylabel(r'$x^2$')
plt.grid(True)
plt.savefig(saveFigPath)
plt.show()
评论列表
文章目录