求助,python3 绘图导入数据时候,坐标图很奇怪!!!!
求助,python3 绘图导入数据时候,坐标图很奇怪!!!!
代码在下面:
from numpy import *
from time import sleep
import matplotlib.pyplot as plt
filename = ‘testSetRBF.txt’
fr = open(filename)
X1 = [];y1 = []
X2 = [];y2 = []
for line in fr.readlines():
lineArr = line.strip().split(’\t’)
if float(lineArr[-1]) == 1:
X1.append(lineArr[0])
y1.append(lineArr[1])
elif float(lineArr[-1]) == -1:
X2.append(lineArr[0])
y2.append(lineArr[1])
plt.scatter(X1[:],y1[:],c=‘r’,s=50)
plt.scatter(X2[:],y2[:],c=‘b’,s=50)
plt.show()
部分数据:-0.214824 0.662756 -1.000000
-0.061569 -0.091875 1.000000
0.406933 0.648055 -1.000000
0.223650 0.130142 1.000000
0.231317 0.766906 -1.000000
-0.748800 -0.531637 -1.000000
-0.557789 0.375797 -1.000000
0.207123 -0.019463 1.000000
0.286462 0.719470 -1.000000
0.195300 -0.179039 1.000000
-0.152696 -0.153030 1.000000
0.384471 0.653336 -1.000000
-0.117280 -0.153217 1.000000
-0.238076 0.000583 1.000000
-0.413576 0.145681 1.000000
0.490767 -0.680029 -1.000000
0.199894 -0.199381 1.000000
-0.356048 0.537960 -1.000000
-0.392868 -0.125261 1.000000
0.353588 -0.070617 1.000000
0.020984 0.925720 -1.000000