plotly / plotly/plotly.py

Opacity and color not working together in px.scatter

Aperta
#4,580 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug P3 sev-3
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

I am creating a plot, which has color and opacity together. When I use color, the opacity doesn't work correctly. Here is a reproducible example:

a = [0.067, 2.159, 0.253, 4.72, 0.614, 4.929, 5.647, 1.624, 0.946, 5.408, 0.308, 0.765, 0.006, 0.326, 4.201, 5.976, 1.644, 4.7, 5.67, 5.002, 5.208, 5.658, 6.821, 6.081, 2.687, 3.106, 0.207, 6.139, 0.242, 4.214, 3.975, 4.639, 5.744, 1.725, 5.753, 7.863, 1.67, 4.466, 5.283, 4.683, 0.764, 5.408, 5.279, 1.088, 0.874, 4.72, 5.39, 0.514, 0.023, 0.196, 2.781, 5.317, 5.262, 4.576, 4.683, 6.437, 6.614, 2.27, 2.92, 2.812, 6.383, 0.486, 6.082, 0.791, 0.283, 0.047, 4.671, 3.362, 0.314, 3.294, 0.134, 3.662, 6.025, 7.097, 2.089, 0.019, 1.058, 6.095, 2.436, 0.563, 5.096, 6.824, 1.707, 1.621, 6.058, 5.621, 0.956, 2.673, 5.751, 3.286, 0.809, 4.468, 6.026, 0.089, 0.29, 5.556, 4.81, 4.811, 5.08, 4.671, 4.614, 6.417, 4.9, 3.398, 6.091, 6.511, 6.46, 5.596, 6.4, 7.219, 5.474, 5.541, 5.542, 5.014, 1.853, 2.726, 4.681, 0.985, 0.114, 0.171, 4.494, 3.783, 0.501, 4.531, 4.424, 5.573, 5.757, 4.991, 5.715, 5.54, 5.127, 4.327, 5.125, 5.545, 4.397, 5.174, 2.417, 2.209, 4.774, 0.095, 0.577, 1.149, 5.158, 1.338, 3.482, 5.143, 0.849, 0.214, 0.113, 3.696, 4.432, 4.29, 4.507, 5.24, 4.158, 4.494, 0.0, 0.851, 5.578, 1.604, 4.856, 4.424, 2.316, 0.259, 1.39, 3.12, 0.446, 1.017, 2.179, 0.017, 3.438, 3.665, 0.538, 1.732, 5.781, 0.241, 0.21, 4.779, 4.519, 0.507, 0.295, 0.956, 5.641, 5.118, 0.9, 4.499, 5.07, 2.568, 1.089, 6.174, 4.45, 0.863, 1.943, 3.451, 3.276, 0.026, 1.378]
b = [int(bool(i<=2)) for i in a]
c = ['r', 'r', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'b', 'r', 'b', 'b', 'b', 'b', 'r', 'b', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'b', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'b', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'r', 'r', 'b', 'r', 'r', 'b', 'r', 'r', 'b', 'r', 'b', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'r', 'r', 'b', 'b', 'r', 'b', 'b', 'r', 'r', 'b', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'r', 'b', 'b', 'b', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'b', 'b', 'b', 'r', 'b', 'r', 'r', 'b', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'b', 'b', 'b', 'r', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'r', 'r', 'b', 'b', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'b', 'b', 'r', 'b', 'b', 'b', 'r', 'r', 'r', 'r', 'b', 'r', 'r', 'r', 'b', 'r', 'r', 'b', 'b', 'b', 'r', 'r', 'b', 'r', 'b', 'b', 'r', 'r', 'r', 'b']

when I use:

fig = px.scatter(y=a,opacity=b,text=['x']*197) 
fig.show()

I get this image, which is correct (anything below 2 has an opacity of 1)
newplot - 2024-04-18T185902 940

but when I use both color and opacity, it gets messed up:

fig = px.scatter(y=a,opacity=b,color=c,text=['x']*197) 
fig.show()

newplot - 2024-04-18T190041 205

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con gli esempi di px.scatter nell’issue ed esegui entrambe le versioni: prima solo opacity, poi opacity combinata con color. Confronta il comportamento del grafico generato per i punti inferiori a 2 e verifica che l’aggiunta di color non modifichi i valori di opacity forniti. Il lavoro è completato quando l’esempio riproducibile esegue correttamente il rendering sia di color sia di opacity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
plotly, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.