# Can't hover on top layer trace for scatter plot

**URL:** <https://community.plotly.com/t/cant-hover-on-top-layer-trace-for-scatter-plot/59123>\
**Category:** 📊 Plotly Python\
**Created:** [December 8, 2021, 10:46am UTC](https://community.plotly.com/t/cant-hover-on-top-layer-trace-for-scatter-plot/59123 "2021-12-08T10:46:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![malteekj](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@malteekj](https://community.plotly.com/u/malteekj)\
**Post date:** [December 8, 2021, 10:46am UTC](https://community.plotly.com/t/cant-hover-on-top-layer-trace-for-scatter-plot/59123/1 "2021-12-08T10:46:51Z")

</div>

I have two scatter plots on top of each other. The first layer has many points (\>10000) and the seconds have the cluster centers. The second is shown on top as I wanted, but one of the these points are on top of a cluster, I only see the hoverlabels from all the points below. I have tried to make the points bigger, but this does not seem to change anything.

Is there a way to give the red points below priority when getting hoverlabels?

I want to get priority of the red points below, but I cannot make them trigger if other points are nearby (the box is from the points below):

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/1/f147a8390fde63165ed7f567e761a8cd587e95db.png)

My code is as follows:

```auto
import plotly.express as px
import plotly.io as pio
import plotly.graph_objects as go

pio.renderers.default='browser'
# pio.renderers.default='svg'

fig = go.Figure(go.Scatter(
    x = pc[1:,0][::-1],
    y = pc[1:,1][::-1],
    marker_color=np.log(y[1:][::-1]),
    hovertemplate =
    '<i>PC 1</i>: %{x:.2f}'+
    '<br><i>PC 2</i>: %{y:.2f}<br>'+
    '%{text}',
    text = ['<b>AA: {}</b><br>index: {}<br>rel: {:.4f}%'.format(
        aa.strip('\'')[:num_seq], i, y_) for i, (aa, y_) in enumerate(zip(df['AA'][1:],y[1:]))][::-1],
    showlegend = False,
    marker_size=15,
    mode='markers',
    # hoveron='points+fills',
    marker=dict(showscale=True,
                colorbar=dict(
                    tickvals=[np.log(y[1:]).min(), np.log(y[1:]).max()],
                    ticktext=['{:.4f}'.format(y[1:].min()), '{:.4f}'.format(y[:1].max())],
                    ))
        )
    )

fig.add_trace(go.Scatter(
    x = mean_trf[:,0],
    y = mean_trf[:,1],
    hovertemplate = '%{text}',
    text = ['index: {}'.format(i) for i in range(len(mean_trf[:,0]))],
    mode='markers',
    marker=dict(
        color='red',
        size=30,
        symbol='circle'
        ),
    showlegend = False,
        )
    )

fig.show()

```

---

<div class="post-metadata">

**Author:** ![ammar](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@ammar](https://community.plotly.com/u/ammar)\
**Post date:** [February 16, 2023, 2:03pm UTC](https://community.plotly.com/t/cant-hover-on-top-layer-trace-for-scatter-plot/59123/2 "2023-02-16T14:03:30Z")

</div>

Is there a way to do this? To give priority to a trace regarding the hover label?
