8000 Scatter plot color array length should raise Error · Issue #3079 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Scatter plot color array length should raise Error #3079
Closed
@hughesadam87

Description

@hughesadam87

Not sure if this behavior is intentional, but if one makes a scatter plot and provides an array for c which is longer than the number of x, y values, instead of raising an error from the arrays being unevenly shaped, it filled in the colors in incorrectly. Here is an example with the correct colors (because 'colors' is the same length as x and y)

x = np.linspace(0,10)
y = np.sin(x)
colors = x
plt.scatter(x,y, c=colors, cmap=mpl.cm.RdBu, s=100)

Here is one where colors is twice the size of x and y:

x = np.linspace(0,10)
y = np.sin(x)
colors = np.linspace(0,10, 100)
plt.scatter(x,y, c=colors, cmap=mpl.cm.RdBu, s=100)

Seems like the intended behavior would be to have an error thrown, or am I mistaken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0