Color palette of seaborn scatterplot is not working

Viewed 3150

I am trying to use the sequential colour brewer palette of seaborn scatter plot, but it does not work properly. This is what I have done so far. I would appreciate any help.

y = [randrange(100) for i in range(50)]
x = [i for i in range(50)]
ax = sns.scatterplot(x, y, s=15, c=y, palette=sns.color_palette("YlOrBr", as_cmap=True))
plt.tight_layout()
plt.show()

Thanks in advance!

1 Answers

palette is tied to hue, so change c to hue:

ax = sns.scatterplot(x, y, s=15, hue=y, palette="YlOrBr", legend=False)
Related