I am trying to plot a 3D graphic of binary classes, with this code:
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
X = np.array([[1,2,1**2+2**2],[1,5,1**2+5**2],[1,7,1**2+7**2],[6,9,6**2+9**2],[7,10,7**2+10**2],[10,3,10**2+3**2],[2,1,2**2+1**2],[5,2,5**2+2**2],[8,1,8**2+1**2],[5,3,5**2+3**2]])
Y = np.array([1,-1,1,-1,1,-1,-1,-1,1,-1])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot3D(X[Y==0,0], X[Y==0,1], X[Y==0,2],'o')
ax.plot3D(X[Y==1,0], X[Y==1,1], X[Y==1,2],'+')
ax.legend(('-1','1'))
ax.set_ylabel(r'$x_2$', usetex = True, fontsize = 15)
ax.set_xlabel(r'$x_1$', usetex = True, fontsize = 15)
ax.zaxis.set_rotate_label(False) # disable automatic rotation
ax.set_zlabel(r'$x_3$', usetex = True, fontsize = 15, rotation = 0)
plt.show()
But the -1
class (blue dots) isn't showing. What am i doing wrong here?