I am using plotly and I try to make a scatterplot colored by a variable, while using another variable to indicate what text should be showed when covering the mouse over a specific point. Look what I tried:
df = pd.DataFrame({
'class': ['A', 'A', 'A', 'A', 'A', 'B', 'B', 'C', 'C', 'C'],
'coord_x': [4,5,6,3,1,-1,9,0,3.5,2],
'coord_y': [11,32,48,22,12,29,32,54,19,21],
'description':['some description for A', 'something else for A', 'other description for A', 'AAA', 'aaa', 'bbb', 'bbb', 'description for C', 'cccc', 'cc']
})
fig = px.scatter(df, x="coord_x", y="coord_y", color="class")
fig.update_traces(hovertemplate="Hover_text: %{text}",
text=[d for d in df.description.values.tolist()])
fig.show()
The code seem to work, but it only the hover works "A" points, even though "B" and "C" don't have the same description in my pandas DataFrame. How should I solve this problem?
