Hello, how would you go about in eliminating or getting rid of the trace-legend inside a hovermode window, especifically in ‘x unified’ or ‘y unified’?
For example, in this simple code with hovermode ‘x unified’, how do i get rid of the trace as shown in the photo?
import plotly.express as px
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df, x="year", y="lifeExp", color="country", title="layout.hovermode='x unified'")
fig.update_traces(mode="markers+lines", hovertemplate=None)
fig.update_layout(hovermode="x unified")
fig.show()
1 Like
Hi @kennethv15 welcome to the forum! It’s not possible to remove this part of the legend, You can hack this behaviour by adding traces with a zero-line width as below, but this is just a hack
import plotly.express as px
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df, x="year", y="lifeExp", color="country", title="layout.hovermode='x unified'")
fig.update_traces(mode="markers+lines", hovertemplate=None, hoverinfo='skip')
fig2 = px.line(df, x="year", y="lifeExp", color="country",
title="layout.hovermode='x unified'")
fig2.update_traces(hovertemplate=None, line_width=0)
fig.add_traces(fig2.data)
fig.update_layout(hovermode="x unified")
fig.show()
Here, 4 years later, is it still the case that it isn’t possible to remove the legend name / symbol in a unified hover?