Hover_data error

Hello, i am trying to use hover_data in a scatter plot but i am always getting the same error: “RuntimeError: dictionary changed size during iteration”. I`ve tried even running the plotly example (Disabling or customizing hover of columns in plotly express) and the result is the same. Any one has an idea what is the problem?

The code is the following:

import plotly.express as px
import numpy as np
df = px.data.iris()
fig = px.scatter(df, x='petal_length', y='sepal_length', facet_col='species', color='species',
                 hover_data={'species':False, # remove species from hover data
                             'sepal_length':':.2f', # customize hover for column of y attribute
                             'petal_width':True, # add other column, default formatting
                             'sepal_width':':.2f', # add other column, customized formatting
                             # data not in dataframe, default formatting
                             'suppl_1': np.random.random(len(df)),
                             # data not in dataframe, customized formatting
                             'suppl_2': (':.3f', np.random.random(len(df)))
                            })
fig.update_layout(height=300)
fig.show()

HI @juanplotly Welcome to the Dash Community. It must be a version problem or something unrelated to your code, because I get a functioning app. I’m using plotly 4.7.0:

3 Likes

Thanks @adamschroeder for the welcome and the solution! I was using plotly 4.5, and that was the problem. Really helpful!

1 Like

For future searchers of this error:

We were getting this error when selecting multiple dots in a chart, but it was intermittent (did not happen every time).

Turns out that we had two callbacks updating the same chart and triggered by the same input, basically doing the same thing twice. The result was this error message.