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
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, cbook.delete_masked_points(), directly with the arguments works as intended, so it appears that something is getting fouled up prior to the function call.
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"?
@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.
Activity
efiring commented on Sep 10, 2014
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, cbook.delete_masked_points(), directly with the arguments works as intended, so it appears that something is getting fouled up prior to the function call.
efiring commented on Sep 10, 2014
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"?
tacaswell commented on Sep 10, 2014
Right by dumb luck!
And that sounds reasonable to me use color as an alias for c.
In fact right now you can pass in both c and color and in some cases it looks like color will over-ride c.
It also looks like facecolor, facecolors, edgecolor and edgecolors will all also have similar problems.
[edit to finish sentence]
WeatherGod commented on Sep 10, 2014
All the more reason for some sort of kwarg normalization function discussed
yesterday...
On Tue, Sep 9, 2014 at 11:01 PM, Thomas A Caswell notifications@github.com
wrote:
3 remaining items
story645 commented on Jun 1, 2016
does #4079 also fix this one?
efiring commented on Jun 1, 2016
@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.
story645 commented on Dec 5, 2016
Sorry had totally spaced out on this. Tested and still broken, but now there's #7570
tacaswell commented on Dec 5, 2016
@story645 Could you review #7570 ?