Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add map_values to Gradient #43
Add map_values to Gradient #43
Changes from 5 commits
0c5bba0
566b705
8328e67
c3edb82
9f0c611
0c1c8af
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should warn the user when values outside of the min/max range are provided, rather than clamping those values silently here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can only speak to my personal usage with colormaps, but if I'm touching the min and max values, it's usually because I'm interested in the middle of the color range, but far-reaching extrema values are decreasing contrast.
Like if your data is spread like this (each
x
a datapoint, each|
the min/max value):The bulk of the data is washed out. In comparison, by setting min/max inside the value range:
You get more contrast in the region you care about.
All this is to say that I personally would not want a warning that I'm doing this, because it would be very intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this use case a bit better, thanks! I do wonder if it would be good to use the
matplotlib
set_extremes
functionality when windowing the data in this way, so that colors over and under the gradient are distinctly marked as out of range. Probably not relevant to your structure viewer use case, but in a heatmap or other context, it would be important to indicate so as to avoid misleading readers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good idea. By name, I thought that
set_extremes
would allow us to avoid normalizing the data altogether, by setting the extrema for the value range. But looking into the implementation, I now see it allows you to control the colors of those outside 0 to 1.This could be useful if we wanted more fancy features and could be accomplished by propagating those args to the
map_values
call signature.Either way, it's noteworthy that the default behavior for
over
andunder
is to clamp the color to the lowest/highest color. Here's a black to white cmap:That's what we we were manually doing. As a step towards implementing
over
/under
/bad
, the clamping op has been removed (0c1c8af).