How to change color of name's label in hover info?

Hi guys!

I would want to know how to change the color of the name’s label in hover info showed in figures, I mean, SF Zoo in the screenshoot.

49

Thanks you very much in advance.

@agarzon

To change hoverlabel color, perform the following update:

fig.update_layout( hoverlabel_font_color='rgb(10,10,10)')

For more info on hoverlabel or hoverlabel_font print:

help(go.Layout.hoverlabel), respectively help(go.layout.Hoverlabel.font)

Hi @empet

Thanks for your answer but, at least in my case, if I use it, it’s (giraffes, 20) what changes its color, not SF Zoo that remains the same.

@agarzon The answer to your question is like this one https://community.plotly.com/t/change-hover-text-color/28039/5 where you should replace scatter by bar. More precisely the name font color is the same as the corresponding bar color.

@empet I understand then that it is impossible to select a different color from that of the bar itself, am I right?

What if I want to change the light grey background behind the text that says “SF Zoo”? Is this possible?

Its not advisable but adding some css does work:

<style>
     <!-- this is the box -->
    .plotly .hoverlayer .hovertext rect {
      fill: white !important;
      fill-opacity: 1 !important
    }
    <!-- this is the text (SF Zoo)-->
    .plotly .hoverlayer .hovertext .name {
      fill: black !important;
    }
</style>
1 Like