Hover data behavior changes based on color/number of traces

I have a scatter chart which updates three other charts based on hovering over a point in the main chart. The updating of the sub charts works correctly when using continuous colors in the main chart, but when I change the colors to use a discrete value, the main chart is now several traces and the hover functionality breaks.

Code to create the main plot;

fig = px.scatter(dffHitGraph,
x=xaxis_column_name, y=yaxis_column_name, size=“PA”,
hover_name=dffHitGraph[‘Player’],
color=“PrimPosNum”,
size_max=30,
height=700)

fig.update_traces(customdata=dffHitGraph['Player'])

This functions correctly and when I dump the JSON of the hover I get the following.

image

If I change the value for the color parameter to “PrimPos” the hover no longer works. PrimPos is a text label with up to 10 distinct values. PrimPosNum (original example which functions correctly) is essentially a mapping of the text to a numerical value that I can use in other places for sorting.

When using text to determine colors, I now get a distinct trace for each value rather than a single trace. I understand that this is the correct behavior, but when I hover, my custom data is no longer correct and the subplots update with the incorrect value.

image

Note that the x and y values are the same, as is the text value for the hover text, but that the curve number and point references are different. When I point at Ted Williams, I see the subplots for Dom DiMaggio. FWIW, if I hover over Dom DiMaggio, I get someone else’s data in the subplots.

I’m sure that there’s a way to address this, but I’ve spent a couple hours reading through the docs and I’m not seeing where I went wrong.