Why adding hue='weekend in scatterplot and get the valueerror? how to fix it

sns.scatterplot(data=flight_sample,x=‘coach_price’,y=‘firstclass_price’,hue=‘weekend’)
plt.show()
plt.clf()

The above this the code, I plot the scatterplot via sns.
However,the hue=‘weekend’ caused the ValueError: not enough values to unpack (expected 2, got 1).

Who know how to fix it?
Appreciate and Thanks you so much

Hm. Good question. There seem to be a number of lines w/issues.

Did you use a subset of data (as the hint suggests) and does that column have more than one value? Though, upon further inspection…I think this issue isn’t the way you used the hue = parameter, but something more/deeper. I’m wondering if it has to do with the version of seaborn or matplotlib.

See:
http://5.9.10.113/68457453/seaborn-lmplot-raises-valueerror-when-set-both-hue-and-scatter-kwss-s

And here,
https://github.com/mwaskom/seaborn/issues/2621

Also, maybe try an lmplot instead. Make sure you add the fit_reg=False parameter too so there are no regression lines)

I did it this way:

sns.lmplot(x ='coach_price', y='firstclass_price', hue = 'weekend', data = flight_sub, fit_reg= False)
plt.show()
plt.clf()

Update:

This issue is happening b/c an older version of Matplotlib (2.0.2) is running in the learning environment. (It’s not an issue of something on your end).
I’ve been told that the LE will be updated sometime in March/April.

In the meantime, I’d use lmplot…b/c that doesn’t throw an error. Even though scatterplot is the preferred way to plot the data.

Happy coding.

2 Likes

Thank you so much.
So, it is not my coding problem
Appreciate

2 Likes