brienna
brienna

Reputation: 1604

ValueError: c argument has n elements, which is not acceptable for use with x with size 0, y with size 0

I am trying to plot a scatterplot using 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
)

I'm getting the error:

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

My data:

I can't understand why I'm getting this error, especially why 'x' and 'y' are not recognized as having any length. I have attempted this with a pandas dataframe instead, where I have an 'x' and 'y' column, then setting x=df['x'] or x=list(df['x']) but I get the same error. How can I plot my tsne_data so that each of its 267,794 point is colored by the color specified at its corresponding index in label_colors?

Upvotes: 2

Views: 1165

Answers (1)

akazuko
akazuko

Reputation: 1394

As per the seaborn documentation you should use the param hue for example:

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
)

Upvotes: 1

Related Questions