Hi, I’m trying to figure out how to add display data on hover in my histogram plot. I have a pandas dataframe with 3 columns: x, y, text. I plot a histogram like so:
fig_hist = px.histogram(df, y='x', x='y', orientation='h')
.
However, when I hover, the only data being displayed are the x and y, not the text column.
I have tried the following without any success:
- I tried to add
hover_name='text'
, but it does not show up neither. - I tried to add
hover_data={'text': True}
, but it doesn’t work neither; however, setting'x': False
was able to make x disappear on hover (same for y). - Lastly I tried
fig_hist.update_traces(hovertemplate='x: %{y}<br> y: %{x}<br> text: %{text}')
, but it’s printing the actual string%{text}
instead of the content. How can I make it to display the content of text, i.e. the 3rd column of the dataframe? (If I just dodf['text']
, then it returns the whole column)