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):
My code is as follows:
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()