godot
godot

Reputation: 1570

Weird thing in seaborn and how to correct it

I'm using Python 2.7.15, seaborn 0.9.0 & matplotlib 2.0.2

When I try to plot 4 points with seaborn scatterplot function, there are all of different colors:

import seaborn as sns
sns.scatterplot(x=range(4), y=[1]*4)

enter image description here

If I do the same with 3 or 5 points, there are all of the same color.

import seaborn as sns
sns.scatterplot(x=range(5), y=[1]*5)

enter image description here

Does anyone know if there is a (good) reason for that or if it is a bug ?

But more important, what do I have to do in order to get the same color for all the 4 points ?

PS: I couldn't reproduce this in Python 3.7

Upvotes: 0

Views: 335

Answers (1)

Rob
Rob

Reputation: 584

I believe you have ran into this issue (which i have also just ran in to, with matplotlib 2.2.3), Issue with Matplotlib scatterplot and Color maps

What is likely happening is seaborn is specifying the colors as a 4 component RGBA value which matplotlib is then interpreting as being a separate color for each individual point, instead of one color for all points.

Upvotes: 1

Related Questions