Px.choropleth hover: template and highlight

Hi!

I am fairly new to plotly / dash, but already a big fan!

Two questions:

  1. in the example for Indexing by GeoJSON Properties, the hover can easily be modified by including e.g. the lines
fig.update_traces(
    customdata= np.stack((df['district'], df['Bergeron']), axis=-1),
    hovertemplate=(
        "<b>%{customdata[0]}</b><br>"+\
        "Votes: %{customdata[1]}"
    )
)

but switching to categorical values / discrete colors breaks the new hovertemplate (displays incorrect information). How come?

  1. also for a choropleth map, what would be the best way to outline / highlight a polygon (district) on hover?

Best,
Jonas

1 Like