Changing color programmatically on hover

Hi, Using the plotly Python to plot some plots and I’d like to change the color of the markers, (in my case on bar and scatter) on hover. I’d like to lighten the colors on hover, something similar to the sass color function lighten(). I’m really not sure how to go about it. Plotly doesn’t seem to give you control over the marker style on hover, at least not from searching the reference. I suppose I could grab all the markers with javascript, read their fill colors, and then reapply them on mouse in/out events, but that seems like too much work.

What’s the best approach here?

Hi @danvallentyne,

Plotly.js doesn’t include hover styling options directly in the plot specification. So you would need to do something involving the hover callback. If you’re working in the Jupyter Notebook or JupyterLab you can do this using a FigureWidget with the on_hover callback mechanism.

You could try something like, but using on_hover rather than on_click.