Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Sep 9, 2025

Add under and over colors to colormaps to make more obvious colors that are out of range.

Before:
Screenshot_20250909_173539
After:
Screenshot_20250909_173154

The colors are created by slightly shifting the first and last color of the colormap in the RGB space.

def _get_cmap(colormap: str | Colormap, nan_color: str | None = None) -> Colormap:
"""
Get a colormap object from a colormap name.
We also set
Copy link
Member

Choose a reason for hiding this comment

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

Incomplete.

Comment on lines +63 to +67
[_shift_color(c, delta * (-1 + 2 * (np.mean(over) > 0.5))) for c in over[:3]]
)
cmap.set_under(
[_shift_color(c, delta * (-1 + 2 * (np.mean(under) > 0.5))) for c in under[:3]]
)
Copy link
Member

Choose a reason for hiding this comment

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

What is the meaning of applying this to the first 3?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to change the alpha/transparency. I'll add a comment.

@nvaytet nvaytet merged commit 1108853 into main Sep 10, 2025
4 checks passed
@nvaytet nvaytet deleted the cmap-under-over branch September 10, 2025 10:57
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.

3 participants