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

Skip to content

Better error message in scatter plot when len(x) != len(c) #7314

Closed
@NelleV

Description

@NelleV
import numpy as np
import matplotlib.pyplot as plt
N = 500
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N+1)

fig, ax = plt.subplots()
ax.scatter(x, y, c=colors)
plt.show()

raises the following error:
ValueError: Invalid RGBA argument: 0.23991184171163127

which is absolutely unrelated to the problem. We need a better error message when the color is not of the correct shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions