Hello, I want to display one tooltip on two subplots since they share the same x axis. Any idea how to make that happen? I’ve already bound the on_hover
event to the first subplot, but how to make it trigger the hover event in the another subplot? Please help
import plotly.graph_objects as go
from plotly.subplots import make_subplots
trace1 = go.Heatmap(
z=df.values.transpose(),
x=df.index,
y=[’/’.join© for c in df.columns],
colorscale=‘Spectral’,
showscale=False,
hoverinfo=‘x+y+z’,
hovertemplate = “index: %{x}
column: %{y}
value: %{z}”,
xaxis=“x”,
yaxis=“y”)
trace2 = go.Heatmap(
z=df.values.transpose()[0:1],
x=df.index,
y=[‘sentiment’],
colorscale=‘Spectral’,
zsmooth=‘best’,
hoverinfo=‘z’,
xaxis=“x”,
yaxis=“y2”)
def hover_fn(trace, points, state):
# —> Trigger hover here <—
pass
trace1.on_hover(hover_fn)
data = [trace1, trace2]
layout = go.Layout(
yaxis=dict(
domain=[0, 0.75]
),
yaxis2=dict(
domain=[0.85, 1]
),
autosize=False,
width=900,
height=220,
margin=go.layout.Margin(
l=30,
r=30,
b=30,
t=30,
pad=10
),
paper_bgcolor=‘white’,
plot_bgcolor=‘white’
)
fig = go.FigureWidget(data=data, layout=layout)
#fig.show(renderer=“png”, width=900, height=220)
fig