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
matplotlib scatter shifts color codes when NaN is present #3489
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 commentedon 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 commentedon 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 commentedon Sep 10, 2014
Right by dumb luck!
And that sounds reasonable to me use
coloras an alias forc.In fact right now you can pass in both
candcolorand in some cases it looks likecolorwill over-ridec.It also looks like
facecolor,facecolors,edgecolorandedgecolorswill all also have similar problems.[edit to finish sentence]
WeatherGod commentedon 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 commentedon Jun 1, 2016
does #4079 also fix this one?
efiring commentedon 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 commentedon Dec 5, 2016
Sorry had totally spaced out on this. Tested and still broken, but now there's #7570
tacaswell commentedon Dec 5, 2016
@story645 Could you review #7570 ?