-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
matplotlib scatter shifts color codes when NaN is present #3489
Comments
Yes, it's a bug; but there is a function call in scatter that is supposed to be handling exactly this situation, and I don't see immediately why it is failing to do so in this instance. It looks like calling the function, |
Aha! @tacaswell was right--the problem was the API. The correct kwarg is "c", not "colors". I don't know what to do about that; maybe pop "colors" off the kwarg list and use it as a synonym for "c"? |
Right by dumb luck! And that sounds reasonable to me use In fact right now you can pass in both It also looks like [edit to finish sentence] |
All the more reason for some sort of kwarg normalization function discussed On Tue, Sep 9, 2014 at 11:01 PM, Thomas A Caswell notifications@github.com
|
does #4079 also fix this one? |
@story645 I suspect it does, possibly in conjunction with later changes. Would you test v2.x with the example given above, please? If you find that the bug no longer appears, I will close this issue. |
Sorry had totally spaced out on this. Tested and still broken, but now there's #7570 |
I want to plot some data with a given color code. For example:
x = np.array([0, 1, 2, 3])
b = np.array([1, 0, 2, 3])
colors = np.array(['g', 'r', 'b', 'y'])
plt.scatter(x, b**2, color=colors)
Great, all the points appear, each one with its color. Now, some data is missing:
plt.figure()
plt.scatter(x, np.log10(b), color=colors)
Here comes the problem: the x=1 data is missing (log(0)=NaN), but the colors are skipping this point and the x=2 point is red, not blue. The solution can be:
y = np.log10(b)
mask = np.isfinite(y)
plt.scatter(x[mask], y[mask], color=colors[mask])
but I feel it so uncomfortable to do this... Any other way? Is this a kind of bug?
Thanks,
Christophe
The text was updated successfully, but these errors were encountered: