Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

How to highlight traces based on legend hover events?

Hi guys,

I want to create a plotly fig that highlight on the hover event an item on the legend.

Is the same animation from this D3js’ example: https://www.d3-graph-gallery.com/bubble.html

My plotly’s code is something like that:

import plotly.graph_objects as go
import plotly.io as pio

fig = go.Figure()

for intent in intents:
    temp = self.data[self.data["intent"] == intent].copy()

    fig.add_trace(go.Scatter(
        x=temp["x"], y=temp["y"],
        mode="markers",
        text=temp["example"],
        opacity=0.6,
        name=intent,
        hovertext=temp["hovertext"],
        hoverinfo="text"
    ))

fig.update_layout(
    title_text="Example Analysis",
)

Someone can help me?