Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix scatter() with empty data and c argument #12672

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

Closed
wants to merge 1 commit into from

Conversation

timhoffm
Copy link
Member

PR Summary

Fixes #12641. The issue is that c[0] is accessed for an empty array (the 3d code drops invalid points and thus passes an empty array in case of the MWE #12641 (comment)).

Note: While the canonical way of checking emptiness is if c, I feel it's more clear to use len(c) > 0 here.

PR Checklist

  • Has Pytest style unit tests

@tacaswell tacaswell added this to the v3.0.x milestone Oct 29, 2018
@tacaswell
Copy link
Member

if c will fail on numpy arrays with "Truth value of an array is ambigious, use .any or .all" ;)

Can you also use safe_first_element instead of c[0]?

@@ -1741,6 +1741,11 @@ def test_scatter_color(self):
with pytest.raises(ValueError):
plt.scatter([1, 2, 3], [1, 2, 3], color=[1, 2, 3])

def test_scatter_empty(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a test for pandas with a non-0 based index?

@ImportanceOfBeingErnest
Copy link
Member

There is also #12673 with the same aim to fix this.

@jklymak
Copy link
Member

jklymak commented Oct 31, 2018

I'm going to close this @TimHoffman, in favour of #12673, because the proposer for that PR put a lot of effort into getting consensus before opening their PR. Hope that's OK....

@jklymak jklymak closed this Oct 31, 2018
@timhoffm timhoffm deleted the fix-scatter-empty-color branch October 31, 2018 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants