Pass nothing (or disable) x-axis hoverformat?

Is there a way to disable plotly from showing anything in the x-axis hoverformat (e.g. a None, “”, or ‘skip’?). I am trying to create a hover that:

  • Contains spikelines
  • Highlights the x point even when not close (so that rules out hovermode=‘closest’)
  • But doesn’t include the x-axis date in the hovertemplate.

The closest I got to was something like this:

import numpy as np
import pandas as pd
import plotly.express as px

dates = pd.date_range("2022-01-01", "2022-03-01")
values = np.random.randint(0, 10, len(dates))
data = pd.DataFrame({"Date": dates, "Value": values})

fig = px.line(data_frame=data, x="Date", y="Value")

fig.update_traces(hovertemplate="%{y}")
fig.update_xaxes(tickformat="%b %-d", hoverformat="I don't want this!")
fig.update_layout(hovermode="x unified")

But as my image below shows, I still have a hoverformat title that I don’t want. Passing in an empty string just uses the default tickformat.

Is there any way to disable it completely? (Whether below the x-axis–like in hovermode=x and in the hoverbox itself)

1 Like