-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plt.scatter, error with NaN values and edge color #19066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From a quick look this really arises from the scatter color parsing machinery which passes an RGB color with an incorrectly masked component to diff --git i/lib/matplotlib/colors.py w/lib/matplotlib/colors.py
index 9aad5b9b0..4c51c342e 100644
--- i/lib/matplotlib/colors.py
+++ w/lib/matplotlib/colors.py
@@ -275,7 +275,7 @@ def _to_rgba_no_colorcycle(c, alpha=None):
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
if len(c) not in [3, 4]:
raise ValueError("RGBA sequence should have length 3 or 4")
- if not all(isinstance(x, Number) for x in c):
+ if not all(isinstance(x, (Number, np.ma.core.MaskedConstant)) for x in c):
# Checks that don't work: `map(float, ...)`, `np.array(..., float)` and
# `np.array(...).astype(float)` would all convert "0.5" to 0.5.
raise ValueError(f"Invalid RGBA argument: {orig_c!r}") as well as silencing the warning that comes below from converting as masked value to a float (which likely throws away all the speedup...). Or #15834 can be cleanly reverted. Still that's only a stopgap; I'd say #15834 really just exposed an issue that was actually introduced in #12422: before #12422, |
The problem is that in |
Bug report
Bug summary
When plotting a
scatter
plot with y containing NaN values, depending on the number of values, an error comes up when setting thecolor
oredgecolor
.This error was introduced with version 3.3.0, might be linked to #17849
Code for reproduction
Here is a basic example
Actual outcome
First analys
It is only affects the
edgecolor
option,facecolor
works fine:It also seem to be only happening when there are 3 values to plot, 1 or 2 of them being NaNs:
Error was discovered through seaborn, mwaskom/seaborn#2373
Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineThe text was updated successfully, but these errors were encountered: