Skip to content

Conversation

dstansby
Copy link
Member

@dstansby dstansby commented Dec 31, 2023

PR summary

This updates the behaviour of PowerNorm to linearly normalize input values < vmin, instead of clipping them.

Fixes #25239; replaces #25256. See discussion at #25256 for more context on this.

PR checklist

@dstansby dstansby mentioned this pull request Dec 31, 2023
6 tasks
@dstansby dstansby marked this pull request as ready for review December 31, 2023 11:22
tacaswell
tacaswell previously approved these changes Jan 3, 2024
@tacaswell tacaswell added this to the v3.9.0 milestone Jan 3, 2024
@dstansby dstansby marked this pull request as draft January 5, 2024 18:43
f, ax = plt.subplots()
cb = Colorbar(ax, norm=PowerNorm(gamma=0.5, vmin=0.0, vmax=1.0),
orientation='vertical', extend='both')
assert cb._values[0] >= 0.0
Copy link
Member Author

@dstansby dstansby Jan 6, 2024

Choose a reason for hiding this comment

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

This check came in with #11610, but from that PR it seems like it's enough just to add the colorbar and check no error or warning is raised. It's expected that _values now has a value < 0 with this PR.

@dstansby dstansby marked this pull request as ready for review January 6, 2024 11:55
@tacaswell tacaswell dismissed their stale review January 8, 2024 22:32

problems founds on subsequent review.

@tacaswell
Copy link
Member

I think going with linear is better because it is invertable, but could we have also fixed the colorbar issue more narrowly by setting the under values to -1 instead of 0?

dstansby and others added 2 commits January 9, 2024 13:21
Co-authored-by: Thomas A Caswell <tcaswell@gmail.com>
@dstansby
Copy link
Member Author

dstansby commented Jan 9, 2024

I think going with linear is better because it is invertable, but could we have also fixed the colorbar issue more narrowly by setting the under values to -1 instead of 0?

Yes, setting everything under to -1 also fixes the colorbar issue.

@QuLogic QuLogic merged commit 6f635b4 into matplotlib:main Jan 10, 2024
@dstansby dstansby deleted the extend-power-norm branch January 10, 2024 10:28
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.

[Bug]: colors.PowerNorm results in incorrect colorbar
3 participants