Python ValueError:c参数有n个元素,不能与大小为0的x和大小为0的y一起使用
我正在尝试使用matplotlib/seaborn绘制散点图: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
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.
我的数据:
-包含267794个元素的Python列表。每个元素都是一个字符串,例如“红色”、“蓝色”、“紫色”label\u colors
-一个包含267794个元素的Numpy 2D数组。每个元素都是x,y坐标,例如tsne_data
。形状为(267794,2)李>[9.417695,-25.48891]
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
)