Skip to content

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

@7hibault

Description

@7hibault

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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions