# Hover data behavior changes based on color/number of traces

**URL:** <https://community.plotly.com/t/hover-data-behavior-changes-based-on-color-number-of-traces/47840>\
**Category:** 📊 Plotly Python\
**Created:** [December 3, 2020, 7:16pm UTC](https://community.plotly.com/t/hover-data-behavior-changes-based-on-color-number-of-traces/47840 "2020-12-03T19:16:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![md9845](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@md9845](https://community.plotly.com/u/md9845)\
**Post date:** [December 3, 2020, 7:16pm UTC](https://community.plotly.com/t/hover-data-behavior-changes-based-on-color-number-of-traces/47840/1 "2020-12-03T19:16:44Z")

</div>

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](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/6e3a76cf0024b0bbf96b143f9f967a9d0171a267.png)

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](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/4/40859be500a9a9f03c3948b5da7a9d547581a28c.png)

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.
