Skip to content

honor zmin/zmid/zmax in annotated_heatmap font colors #2921

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 3 commits into from
Nov 26, 2020

Conversation

nicolaskruchten
Copy link
Contributor

Alternative to #2892 to close #2187, cc @bensdm.

This is a more targeted fix for the zmin/zmax problem specifically, and doesn't address the difficulty of light colors in the middle range of a diverging colorscale.

@nicolaskruchten nicolaskruchten merged commit b409770 into master Nov 26, 2020
@@ -189,6 +189,23 @@ def __init__(
self.reversescale = reversescale
self.font_colors = font_colors

if np and isinstance(self.z, np.ndarray):
self.zmin = np.amin(self.z)
self.zmax = np.amax(self.z)
Copy link

@bensdm bensdm Nov 27, 2020

Choose a reason for hiding this comment

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

I think we should use np.nanmin and np.nanmax

annotations = []
for n, row in enumerate(self.z):
for m, val in enumerate(row):
font_color = min_text_color if val < z_mid else max_text_color
font_color = min_text_color if val < self.zmid else max_text_color
Copy link

Choose a reason for hiding this comment

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

what about diverging colorscale?

@archmoj archmoj deleted the annotated_heatmap_colors branch November 23, 2021 23:34
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.

Annotated heatmaps: font colour blends with the colour of the square when using zmin and zmax
2 participants