I have multiple values plotted on the y-axis. I pass in another column through custom_data
which I don’t want to be visualised but want it to show up in the hovertext. How can I make this 3rd value appear only once?
import plotly.express as px
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df.loc[df['country'] == 'Australia'], x="year", y=["lifeExp", "iso_num"], color="country", title="layout.hovermode='closest' (the default)", custom_data=df[['gdpPercap']])
fig.update_layout(hovermode="x unified", )
fig.update_traces(
mode="markers+lines",
hovertemplate="%{y} <br> gdpPercap=%{customdata[0]}"
)
fig.show()
The hovertext looks like this
Expected hovertext:
1970
lifeExp = A
iso_num = B
gdpPercap = C