【发布时间】:2020-06-12 16:08:40
【问题描述】:
我在绘制点时遇到问题。我对python不太了解,我还在学习中。
这是我的代码:
def graph(features, labels,classes):
plt.plot(features[labels[:]==1,0], features[labels[:]==1,1],'g^',
features[labels[:]==0,0],features[labels[:]==0,1],'rs')
plt.axis([-4, 4,-4, 4])
plt.xlabel('x: feature 1')
plt.ylabel('y: feature 2')
plt.legend(['Class'+str(classes[1]), 'Class'+str(classes[0])])
plt.show()
features=np.array([[1,1], [1,0], [0,1], [-1,-1], [0.5,3], [0.7,2], [-1,0], [-1,1], [2,0], [-2,-1]])
labels=np.array([1,1,-1,-1,1,1,-1,-1,1,-1])
classes=[0,1]
当我运行代码时,输出如下: Plotting points
【问题讨论】:
-
期望的输出是什么?
标签: python matplotlib plot