`go.Scatter()`: text becomes semi transparent

Hi,

I create the figure in the following way:

        fig = go.Figure()
        scatter = go.Scatter(
            x=df[scatter_x],
            y=df[scatter_y],
            text=df["title"],
            mode='markers+text',
            marker=dict(color=df["color"], size=3),
        )
        fig.add_trace(scatter)

        # Update text color
        fig.for_each_trace(lambda t: t.update(textfont_color=t.marker.color, textposition='top center'))

but the I can see that some text labels have some transparency like in the picture.
Why this is happen? And how to control that?

Hey @kerim hard to tell without your data (or equivalent dummy data)

1 Like

@AIMPED thank you for response!

I uploaded the file to the Google Drive.
It is a CSV file where x and y columns are the x and y for the scatter.

To reproduce the issue try the following code:

import plotly.graph_objects as go
import pandas as pd
import numpy as np

df = pd.read_csv("data_for_plotly_forum.csv", index_col=0).reset_index(drop=True)

fig = go.Figure()
scatter = go.Scatter(
    x=df["x"],
    y=df["y"],
    text=df["title"],
    mode='markers+text',
    marker=dict(color=df["color"], size=3)
)
fig.add_trace(scatter)

fig.data[0].update(
    selectedpoints=[],
    selected={"marker": {"color": "red"}},
    unselected={"marker": {"opacity": 0.8}},
)

# Update text color
fig.for_each_trace(lambda t: t.update(textfont_color=t.marker.color, textposition='top center'))

The issue happens only if I set selectedpoints=something.

Plotly version: 5.24.0

Not sure what you are actually trying. But on select, all markers not selected, are shown like this. That’s a intended behavior.

@AIMPED actually markers are fine.
Something wrong with the text.
It is semi transparent even markers are opaque.