matplotlib分散的传奇

时间:2017-07-01 09:53:23

标签: python matplotlib

<host>

如您所见,我将from numpy import * import matplotlib import matplotlib.pyplot as plt import matplotlib.patches def file2martix(filename): fr = open(filename) arryOfLines = fr.readlines() numbersOfLines = len(arryOfLines) print(numbersOfLines) returnMat = zeros((numbersOfLines,3)) print(returnMat) classLableVector = [] index = 0 for line in arryOfLines: line = line.strip() listFromLine = line.split('\t') returnMat[index,:] = listFromLine[0:3] print(listFromLine[0:3]) classLableVector.append(int(listFromLine[-1])) index = index + 1 return returnMat,classLableVector datingDataMat,datingLables = file2martix('1.txt') fig = plt.figure() ax = fig.add_subplot(111) color = ['yellow','green','blue'] ax.scatter(datingDataMat[:,1],datingDataMat[:,2],s = 15,c = color) print(datingLables) plt.legend(color[0:2], loc=0, ncol=4) plt.show() 设置为color来控制功能 - 图例,颜色是一个列表。  问题是当运行时,图片中的图例只显示第一个元素 - &#39;黄色&#39;  它有什么问题?  我希望图片的传奇可以展示关于这一点的三个要素

我喜欢创造三个情节的问题,尽管颜色的情节可以一个接一个。

label

0 个答案:

没有答案
相关问题