plot numpy 的逻辑索引如何从下面代码片段中的“数据”变量中获取数据点?我知道第一个参数是 x 坐标,第二个参数是 y 坐标。我不确定它如何映射到变量中的数据点。
data = vstack((rand(150,2) + array([.5,.5]),rand(150,2)))
# assign each sample to a cluster
idx,_ = vq(data,centroids)
# some plotting using numpy's logical indexing
plot(data[idx==0,0],data[idx==0,1],'ob',
data[idx==1,0],data[idx==1,1],'or')
plot(centroids[:,0],centroids[:,1],'sg',markersize=8)