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

Skip to content

Add 3D scatter test for cmap update #30062

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

Merged
merged 1 commit into from
May 18, 2025

Conversation

MiniX16
Copy link
Contributor

@MiniX16 MiniX16 commented May 17, 2025

PR summary

This PR adds a new test to verify that changing the colormap of a 3D scatter plot (Axes3D.scatter) after drawing the figure properly updates the face colors.

Why is this change necessary?

There was previously no test ensuring that colormap updates on 3D scatter plots are reflected after a figure draw. This test ensures consistency with 2D behavior and guards against regressions.

What problem does it solve?

Confirms that calling set_cmap() after drawing does in fact update the plotted colors in 3D, which has historically been a bug but seems to be fixed.

What is the reasoning for this implementation?

The test draws a 3D scatter plot with an initial colormap ('jet'), forces a draw, changes the colormap to 'viridis', and compares it against a reference plot created directly with 'viridis'.

This ensures the update mechanism behaves correctly post-render.

Minimal example

sc = ax.scatter(x, y, z, c=values, cmap='jet')
fig.canvas.draw()
sc.set_cmap('viridis')

Closes #18931


PR checklist

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot - looks good to me.

@oscargus
Copy link
Member

Thanks and congratulations on your first merged PR in Matplotlib. Looks that there may be two soon. Hoping to see you around!

@oscargus oscargus merged commit 35c5481 into matplotlib:main May 18, 2025
39 checks passed
@QuLogic QuLogic added this to the v3.11.0 milestone May 20, 2025
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.

3D collections do not proper handle edgecolor='face'
4 participants