Any way to have both "x unified" and "y unified" for hovermode (like crosshair)?


I am able to call fig.update_layout(hovermode="x unified") to have a vertical (or horizontal with x unified) line when my mouse hovers my chart like this:


I know Plotly can draw both “x unified” and “y unified” together so that I can get a crosshair on my chart. How can I have a crosshair on my chart with Plotly Python?

Thank you,

Hi @python-trader,

Try this:

fig.update_xaxes(showspikes=True, spikemode="across")
fig.update_yaxes(showspikes=True, spikemode="across")

Additionally you can also set spikesnap="cursor" on both the axes to always show the spikelines on mouse hover instead of just appearing when hovering over the Line

1 Like