Python ValueError:c参数有n个元素,不能与大小为0的x和大小为0的y一起使用

Python ValueError:c参数有n个元素,不能与大小为0的x和大小为0的y一起使用,python,matplotlib,seaborn,valueerror,Python,Matplotlib,Seaborn,Valueerror,我正在尝试使用matplotlib/seaborn绘制散点图: plt.figure(figsize=(16,10)) sns.scatterplot( x=[i[0] for i in tsne_data], y=[i[1] for i in tsne_data], alpha=0.3, color=label_colors ) 我得到了一个错误: ValueError: 'c' argument has 267794 elements, which is n

我正在尝试使用matplotlib/seaborn绘制散点图:

plt.figure(figsize=(16,10))
sns.scatterplot(
    x=[i[0] for i in tsne_data],
    y=[i[1] for i in tsne_data],
    alpha=0.3,
    color=label_colors
)
我得到了一个错误:

ValueError: 'c' argument has 267794 elements, which is not acceptable for use with 'x' with size 0, 'y' with size 0.
我的数据:

  • label\u colors
    -包含267794个元素的Python列表。每个元素都是一个字符串,例如“红色”、“蓝色”、“紫色”
  • tsne_data
    -一个包含267794个元素的Numpy 2D数组。每个元素都是x,y坐标,例如
    [9.417695,-25.48891]
    。形状为(267794,2)
我不明白为什么会出现这个错误,特别是为什么“x”和“y”没有被认为有任何长度。我尝试使用pandas数据帧,其中有一个“x”和“y”列,然后设置
x=df['x']
x=list(df['x'])
。如何绘制我的
tsne_数据
,使其267794点的每个点都由
label_colors
中相应索引处指定的颜色进行着色?

根据,您应该使用参数
色调
,例如:

plt.figure(figsize=(16,10))
sns.scatterplot(
    x=[i[0] for i in tsne_data],
    y=[i[1] for i in tsne_data],
    alpha=0.3,
    hue=label_colors
)