I want spikelines on, but absolutely no floating hover data text box because it ends up covering the horizontal spike line.
The closest I’ve gotten is
fig.update_traces(hovertemplate=" ") (one space) which makes a very small empty text box but it still shows the name of the data line I hover over.
hovermode = None also turns off the spikelines. I’m doing this in Dash with the graph coming from plotly express from a
I have a checkbox that will, I hope, turn off the hover text and show the spikes instead (or maybe two checkboxes) but right now I can’t make the hover text go away and keep the spikelines.
You could use the
hoverinfo property in your
.update_traces() to control the hoverinfo on the graph.
With a graph_objects figure you could simply set
hoverinfo='none' and disable the hoverinfo on the graph.
But Plotly Express uses the new
hovertemplate mechanism for its hovers, so you’ll also need to set
hoverinfo='skip' in your
Here’s an example with
import plotly.express as px
df = px.data.gapminder().query("country=='India'")
fig = px.line(df, x="year", y="lifeExp", color="country", title="Spike lines active")
fig.update_layout(title="Spike lines active, hoverinfo off")
Awesome, thank you! I decided that fully off may not be as good as
hovermode='x' so I just put in radioitems choices for three hover text options (minimal, full, none). Implemented live now on my covid case tracker, thank you!
(Added a screenshot)
Nice, such a cool dashboard @marcosh