Skip to content

Honor cmap for numeric scatter colors#616

Merged
cvanelteren merged 5 commits intomainfrom
fix/scatter-cmap-615
Mar 17, 2026
Merged

Honor cmap for numeric scatter colors#616
cvanelteren merged 5 commits intomainfrom
fix/scatter-cmap-615

Conversation

@cvanelteren
Copy link
Collaborator

This fixes a Matplotlib-compatibility bug in ax.scatter(...) when c is a 1D numeric array. UltraPlot was treating short numeric sequences like [0.1, 0.2, 0.3, 0.4] as literal colors too early, which caused cmap to be dropped as unused instead of applying colormapping. The fix keeps explicit N x 3 / N x 4 RGB(A) handling intact, but treats 1D numeric arrays matching the point count as scalar data for colormapping, which is the behavior users expect from Matplotlib. A regression test covering the reported c=[...], cmap="turbo" case is included.

Closes #615.

Treat 1D numeric scatter c arrays matching the point count as scalar data for colormapping instead of literal RGBA colors. This preserves Nx3/Nx4 explicit color support, keeps the Matplotlib-compatible cmap behavior for numeric values, and adds a regression test for issue #615.
@cvanelteren cvanelteren force-pushed the fix/scatter-cmap-615 branch from 2aa6748 to ce73924 Compare March 17, 2026 00:07
Annotate the scatter-specific color parsing helpers touched by the cmap compatibility fix so the intent of the new parameters and return values is explicit without broadening the typing changes beyond the affected code path.
@cvanelteren
Copy link
Collaborator Author

Reminder: review this later today.

Document the scatter color ambiguity resolved by the PR: one-dimensional numeric arrays matching the point count are treated as scalar colormap data, while explicit RGB(A) colors should be passed as N x 3 / N x 4 arrays or via color=.
Replace the loose Any annotations on the scatter color parsing helpers with explicit data and color input aliases based on ArrayLike and color tuples. This keeps the typing aligned with the actual ambiguity being resolved by the cmap fix while staying practical for plotting inputs.
@cvanelteren cvanelteren merged commit 3ff8455 into main Mar 17, 2026
15 checks passed
@cvanelteren cvanelteren deleted the fix/scatter-cmap-615 branch March 17, 2026 00:56
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.

ax.scatter Ignores "cmap" Argument When 'c' Argument is a List of Values Between 0 and 1

1 participant