Take this code of a simple plotly plot. I want to modify the highlighted area and populate it based on another array (let it be q
) (or have both the original value and q
displayed). How can I do that?
import plotly.graph_objects as go
x = [1, 2, 3, 4, 5]
y1 = [2, 4, 6, 4, 2]
y2 = [5, 3, 1, 3, 5]
y3 = [3, 6, 9, 6, 3]
q = ["A", "B", "C", "D", "E"]
trace1 = go.Scatter(x=x,
y=y1,
name='Trace 1',
hovertemplate='Trace 1: %{y}<extra></extra>')
trace2 = go.Scatter(x=x,
y=y2,
name='Trace 2',
hovertemplate='Trace 2: %{y}<extra></extra>')
trace3 = go.Scatter(x=x,
y=y3,
name='Trace 3',
hovertemplate='Trace 3: %{y}<extra></extra>')
traces = [trace1, trace2, trace3]
layout = go.Layout(hovermode='x unified')
fig = go.Figure(data=traces, layout=layout)
widget = go.FigureWidget(fig)
widget