Skip to content

fix annotations font color #2892

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

Closed
wants to merge 5 commits into from
Closed

Conversation

bensdm
Copy link

@bensdm bensdm commented Nov 11, 2020

Correct the font annotation color when using zmin and zmax or zmid #2187
image
image
image

@nicolaskruchten
Copy link
Contributor

Thanks for this pull request! I'll try to review and merge it soon. The build failure is odd and I've seen it before but it doesn't make a ton of sense. I'll look into it :)

zmid = (zmax + zmin) / 2
if min_text_color == max_text_color:
# diverging colorscale
mid_text_color = "#000000"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is a great default... this is assuming the diverging scale is light in the middle?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we shouldn't accept a third color in font_colors for this and only set this one here if it's not present?

Copy link
Author

Choose a reason for hiding this comment

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

Yes can be an option but is there any diverging colorscale where the it's not the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, users can pass in their own colorscale, they're not limited to just the built-in ones.

"""
Get annotations for each cell of the heatmap with graph_objs.Annotation

:rtype (list[dict]) annotations: list of annotations for each cell of
the heatmap
"""
min_text_color, max_text_color = _AnnotatedHeatmap.get_text_color(self)
z_mid = _AnnotatedHeatmap.get_z_mid(self)
if zmin is None or zmax is None:
zmin, zmax = _AnnotatedHeatmap.get_z_min_max(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

here it seems like we overwrite both if either is missing? probably best not to do that I think.

Copy link
Author

Choose a reason for hiding this comment

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

From what I understand from the doc https://plotly.github.io/plotly.py-docs/generated/plotly.graph_objects.Heatmap.html "zmax – Sets the upper bound of the color domain. Value should have the same units as in z and if set, zmin must be set as well." we can not pass only one of these 2 thats why i overwrite both

Copy link
Contributor

Choose a reason for hiding this comment

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

This is true of the underlying heatmap trace, yes, but this figure-factory already does its own bounds-computation, so we may as well reuse it. I've already addressed this comment in #2921.

@nicolaskruchten
Copy link
Contributor

Thanks for this PR! It's prompted me to make this one #2921 which is a bit more targeted and doesn't change any method signatures etc. I'd love your thoughts on the other one, and if we merge that then you can try to build on it to address the color problem in diverging colorscales?

@gvwilson gvwilson closed this May 27, 2024
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.

4 participants