Python 绘制带有9个不同标签的三维散点时出现问题

Python 绘制带有9个不同标签的三维散点时出现问题,python,python-3.x,python-2.7,Python,Python 3.x,Python 2.7,有一个Xnp.array,它类似于 array([[ 4.94267554, -6.22892343, -2.3546827 ], [ 6.9644885 , -1.15783767, 1.41377245], [ 0.97948001, 1.92804306, -3.61947 ],....]) 并且该矩阵的每一行的标签在y中。标签是所有可能的标签([0,1,2,3,4,5,6,7,8,9]) 我想在三维散点图中解释所有这些信息 我的函数是这样的: fro

有一个
X
np.array,它类似于

array([[ 4.94267554, -6.22892343, -2.3546827 ],
       [ 6.9644885 , -1.15783767,  1.41377245],
       [ 0.97948001,  1.92804306, -3.61947   ],....])
并且该矩阵的每一行的标签在
y
中。
标签是所有可能的标签([0,1,2,3,4,5,6,7,8,9])

我想在三维散点图中解释所有这些信息

我的函数是这样的:

from mpl_toolkits.mplot3d import Axes3D

plt.ion()

def plot_features(X, feature_idx, y, labels):
     fig, ax = plt.subplots()
     zeros = ax.scatter(
        X[y == 0, feature_idx[0]],
        X[y == 0, feature_idx[1]],
        X[y == 0, feature_idx[2]],
        label=labels[0], c='orange', alpha=0.3, s=100, projection='3d')
     ones = ax.scatter(
        X[y == 1, feature_idx[0]], 
        X[y == 1, feature_idx[1]],
        X[y == 1, feature_idx[2]],
        label=labels[1], c='blue', alpha=0.3, s=100, projection='3d')
    twos = ax.scatter(
        X[y == 2, feature_idx[0]], 
        X[y == 2, feature_idx[1]],
        X[y == 2, feature_idx[2]],
        label=labels[2], c='yellow', alpha=0.3, s=100, projection='3d')
    threes = ax.scatter(
        X[y == 3, feature_idx[0]], 
        X[y == 3, feature_idx[1]],
        X[y == 3, feature_idx[2]],
        label=labels[3], c='red', alpha=0.3, s=100, projection='3d')
    fours = ax.scatter(
        X[y == 4, feature_idx[0]], 
        X[y == 4, feature_idx[1]],
        X[y == 4, feature_idx[2]],
        label=labels[4], c='black', alpha=0.3, s=100, projection='3d')
    fives = ax.scatter(
        X[y == 5, feature_idx[0]], 
        X[y == 5, feature_idx[1]],
        X[y == 5, feature_idx[2]],        
        label=labels[5], c='cyan', alpha=0.3, s=100, projection='3d')
    sixs = ax.scatter(
        X[y == 6, feature_idx[0]], 
        X[y == 6, feature_idx[1]],
        X[y == 6, feature_idx[2]],
        label=labels[6], c='purple', alpha=0.3, s=100, projection='3d')
    sevens = ax.scatter(
        X[y == 7, feature_idx[0]], 
        X[y == 7, feature_idx[1]],
        X[y == 7, feature_idx[2]],
        label=labels[7], c='green', alpha=0.3, s=100, projection='3d')
    eights = ax.scatter(
        X[y == 8, feature_idx[0]], 
        X[y == 8, feature_idx[1]],
        X[y == 8, feature_idx[2]],
        label=labels[8], c='grey', alpha=0.3, s=100, projection='3d')
    nines = ax.scatter(
        X[y == 9, feature_idx[0]], 
        X[y == 9, feature_idx[1]],
        X[y == 9, feature_idx[2]],
        label=labels[9], c='magenta', alpha=0.3, s=100, projection='3d')

     plt.title("3d decomposition plot")
     ax.grid(True)

     plt.show()
你知道怎么修吗