Scatterplot (and possibly others?) fail when specifying a color list manually
See original GitHub issueMatplotlib’s scatterplot allows to manually specify the color for each dot. From the documentation of seaborn.scatterplot
, I see that additional kwargs
should be passed on to matplotlib’s scatterplot, i.e., I should be able to set that color list.
However, here is a minimal example that leads to a crash:
import pandas as pd
import seaborn as sns
data = [{"x": x, "y": y} for x in range (0,5) for y in range(0,5)]
df = pd.DataFrame(data)
colors = [ "#000000" ] * len(data)
sns.scatterplot(x="x", y="y", color=colors, data=df)
The problem, as far as I can tell, is the magic with which seaborn determines colors in line 740 of relational.py
. Here, an empty plot is attempted with the kwargs
passed, which leads to a mismatch in the length of the c
, x
and y
fields.
I’m not sure what the best solution would be. If the empty plot in line 740 is only needed for the colors, one might want to skip it when colors are specified manually?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Setting different color for each series in scatter plot on matplotlib
The normal way to plot plots with points in different colors in matplotlib is to pass a list of colors as a parameter....
Read more >scatter plot different colors and markers based on ... - MathWorks
I would like to make a scatter plot showing the different samples with a different colour and the subcategories with a different marker....
Read more >Solved: Scatter plot colours - Microsoft Power BI Community
I am not able to find how to change data colours on the scatter chart. ... one (let s say black) and then...
Read more >Visualizing Data in Python Using plt.scatter()
In this tutorial, you'll learn how to create scatter plots in Python, which are a key part of many data visualization applications.
Read more >Add Multiple Series of Data to X Y Scatter Chart - YouTube
If you're creating a scatter plot it may begin with one series of x,y data. But later on you may want to put...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately I guess the answer is that this is broken on newer matplotlib versions, and I see no value in trying to convince upstream otherwise; sorry about that.
For some reason the matplotlib developers are constantly changing the
c
/color
functionality. I think this is an irritating example where they’ve made an uneccessary (imo) change and broken seaborn.