You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scatter produce multiple colors for a single RGB/RGBA input #17423
Scatter docs say that in order to provide a single RGB/RGBA color for all scatter elements, it is required to pass a 2D array with a single row for c argument input:
If you want to specify the same RGB or RGBA value for all points, use a 2-D array with a single row. Otherwise, value- matching will have precedence in case of a size matching with x and y.
When x/y shape is 3 and RGB is passed as a 2D array with a single row (e.g. c=[[1, 0.5, 0.05]]), or when x/y shape is 4 and RGBA is passed as a 2D array with a single row, the plot elements have several different colors (taken from the default colormap?) while all should have the same color. The problem occurs for both plt.scatter and ax.scatter calls, and also if c input is provided as a numpy array of shape (1,3) for RGB or (1,4) for RGBA instead of a nested list.
I'm not actually sure why we want to flatten c since the docs say "If you want to specify the same RGB or RGBA value for all points, use a 2-D array with a single row.", but it should work if c is the same length as x/y.
IMO this is a pretty serious regression; it makes seaborn plots wrong with no straightforward way for the user to work around it. Could it please get a release critical tag?
If you know ahead of time that you want to specify an RGG(A) color not values to be colormapped you can use the color kwarg which has none of the ambiguity.
seaborn.scatterplot can produce varying-color scatterplots though. It would be possible to check the shape of the color array after semantic mapping and conditionally dispatch to different matplotlib kwargs, but boy would it be messy...
Activity
story645 commentedon May 15, 2020
This is a regression bug because it works as expected on 3.1.2

QuLogic commentedon May 15, 2020
Bisects to 5a5c2f6, or #13959 by @efiring.
I'm not actually sure why we want to flatten
csince the docs say "If you want to specify the same RGB or RGBA value for all points, use a 2-D array with a single row.", but it should work ifcis the same length asx/y.mwaskom commentedon May 23, 2020
IMO this is a pretty serious regression; it makes seaborn plots wrong with no straightforward way for the user to work around it. Could it please get a release critical tag?
FIX: fix support for single color 2D array as c to mean single color
tacaswell commentedon May 23, 2020
If you know ahead of time that you want to specify an RGG(A) color not values to be colormapped you can use the
colorkwarg which has none of the ambiguity.See #17499 for fix.
mwaskom commentedon May 23, 2020
seaborn.scatterplotcan produce varying-color scatterplots though. It would be possible to check the shape of the color array after semantic mapping and conditionally dispatch to different matplotlib kwargs, but boy would it be messy...tacaswell commentedon May 23, 2020
We currently have that code in mpl and it is rather messy (which is why it keeps breaking :/ )