Skip to content
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

ValueError exception when plotting a legend on an empty scatter graph with marker size = data length #4365

Closed
7hibault opened this issue Apr 21, 2015 · 1 comment
Assignees
Milestone

Comments

@7hibault
Copy link

Issue raised on Stack Overflow by burak1000: Legends for scatter plots with NANs in matplotlib

When a scatter plot is created with (x=[NaN], y=[NaN]), a call to legend will raise a ValueError exception. The error appears when the two conditions are met while calling scatter:

  1. The length of s= (marker size) is equal to the data length
  2. No points are plotted, i. e. for each index, x[index] or y[index] is NAN or INFINITY
    For example, this will also raise the exception:
    scatter([NAN, 2], [3, NAN], marker="o", s=[3, 4])

burak1000 provided more information about the issue on SO!

@tacaswell tacaswell added this to the next point release milestone Apr 21, 2015
@7hibault 7hibault changed the title One element NaN scatter plots raising ValueError exception when trying to add a legend ValueError exception when plotting a legend on an empty scatter graph with marker size = data length Apr 22, 2015
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jul 16, 2015
In HandlerRegularPolyCollection gracefully deal with empty
size lists.

Fixes matplotlib#4365
@tacaswell
Copy link
Member

Oddly, this works correctly with empty lists, but not with nans floating around, but I suspect that this is due to some nastyness in handling the normalization of the input to scatter.

Have a PR on the way.

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

No branches or pull requests

2 participants