plotly / plotly/plotly.py

Scattergl and px.line fill and continuous error bands don't appear

Aperta
#3,194 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Summary

Using the fill and fillcolor parameters on scattergl traces (to produce continuous error bands, for example) does not work.

Issue

The issue is specific to scattergl traces: the same parameters work fine with scatter traces. To avoid the problem with plotly.express px.line() calls requires using render_mode="svg" to avoid the use of scattergl traces.

Using graph_objects has the some problem: one must use go.Scatter() and not go.Scattergl() to get error bands.

The reference for scattergl traces (https://plotly.com/python/reference/scattergl/#scattergl-fill) indicates that the behaviour should be the same as for scatter.

Specs

Python Version: 3.8.6
Plotly Version: 4.14.3
Kaleido Version: 0.2.1

  • For image exports to be pasted here (they all looked the same as rendered in the browser)

Browsers: Firefox 88.0, Safari 12.1.1

Example

import numpy as np
import pandas as pd
import plotly.express as px

# dummy data
x = np.linspace(0, 10000, num=10_000)

df = pd.DataFrame({'x': x, 'y': x**2})
df['y_err_plus'] = df['y'] * 1.1
df['y_err_minus'] = df['y'] * 0.95
# use webgl and no fill

fig = (
px
 .line(
    df, x='x', y=['y', 'y_err_minus','y_err_plus'], 
    render_mode='webgl')
 .update_traces(
     fill='tonexty', fillcolor='red',
     selector={'name':'y_err_plus'}
 )
)
fig

fill_test

# use svg to get fill

fig = (
px
 .line(
    df, x='x', y=['y', 'y_err_minus','y_err_plus'], 
    render_mode='svg')
 .update_traces(
     fill='tonexty', fillcolor='red',
     selector={'name':'y_err_plus'}
 )
)
fig

fill_working

Sanity Check: fill to zero works?

Yes.

fig = (
px
.line(
    df, x='x', y='y', 
    render_mode='webgl')
.update_traces(fill='tozeroy')
)

fig

fill_zero

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

Riproduci il problema con px.line(render_mode="webgl") o go.Scattergl() usando fill="tonexty" e fillcolor, quindi confrontalo con i casi funzionanti di scatter e render_mode="svg". Traccia il percorso di rendering di scattergl e la gestione esistente di fill; il lavoro è completato quando le bande di errore continue vengono renderizzate in webgl, mentre il comportamento esistente di tozeroy rimane corretto.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.