Try changing this to
selector=dict(mode="markers+text")
Example code:
import plotly.express as px
import numpy as np
x = np.random.randint(10, 50, 10)
y = np.random.randint(10, 50, 10)
text = np.random.randint(1, 3, 10)
fig = px.scatter(
x=x,
y=y,
text=text
)
fig.update_traces(
marker=dict(
symbol="square",
color='red',
size=20,
line=dict(width=2, color="DarkSlateGrey") ),
selector=dict(mode="markers+text"),
)
Creates:
EDIT: you might even delete the selector
parameter if you do wanted to change all traces in your figure.