How to edit the hoverinfo/hoverformat in plotly-python?

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

Hi, does this help?

Hi,

I’m sorry, but that seems to behave differently when using layout = go.Layout(hovermode='x unified').

So it turns out that editing that text is only possible if you edit the ticks as well. Please see more details here: Display different ticktext for hover and axis Β· Issue #4278 Β· plotly/plotly.py (github.com)

Editing only that text is not possible as of today, hopefully in a future update.