I am playing with examples from plotly.express piechart help page and trying to add an extra element iso_num
to the hover_data property (iso_num
is an int64 column in the gapminder dataframe)
import plotly.express as px
df = px.data.gapminder().query("year == 2007").query("continent == 'Americas'")
fig = px.pie(df, values='pop', names='country',
title='Population of American continent',
hover_data=['lifeExp','iso_num'], labels={'lifeExp':'life expectancy','iso_num':'iso num'
})
fig.update_traces(textposition='inside', textinfo='percent+label')
fig.show()
Hovering over the slice of the pie chart then gives this:
where iso num
value is %{customdata[1]}
instead of the numeric value from the column.
What am I missing?
Thanks!