plotly / plotly/plotly.py

Align the use of `y=` argument with `error_y` in `plotly.express`

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

Nessuno ha ancora preso questa issue.

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

Descrizione

At the moment, I can plot multiple y series with an API that looks like this:

import pandas as pd
import plotly.express as px

data = {
    'X_Values': pd.date_range(start='2023-01-01', periods=10, freq='D'),
    'Y1_Values': [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],
    'Y2_Values': [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
    'Y3_Values': [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
}
df = pd.DataFrame(data)

px.scatter(df, x='X_Values', y=['Y1_Values', 'Y2_Values', 'Y3_Values'])

I would expect to be able to provide an array of error bars for each of the y's but that doesn't seem to be the case:

import pandas as pd
import plotly.express as px

data = {
    'X_Values': pd.date_range(start='2023-01-01', periods=10, freq='D'),
    'Y1_Values': [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],
    'Y1_Errors': [0.5, 0.6, 0.7, 0.5, 0.8, 0.5, 0.7, 0.6, 0.5, 0.7],
    'Y2_Values': [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
    'Y2_Errors': [0.3, 0.5, 0.4, 0.6, 0.7, 0.5, 0.6, 0.4, 0.5, 0.6],
    'Y3_Values': [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
    'Y3_Errors': [0.4, 0.3, 0.6, 0.5, 0.7, 0.4, 0.5, 0.3, 0.6, 0.5],
}
df = pd.DataFrame(data)

px.scatter(df, x='X_Values', y=['Y1_Values', 'Y2_Values', 'Y3_Values'], error_y=['Y1_Errors', 'Y2_Errors', 'Y3_Errors'])

but this fails with

ValueError: All arguments should have the same length. The length of argument `error_y` is 3, whereas the length of  previously-processed arguments ['X_Values'] is 10

Can this get similar semantics to an array-like object in the y= argument?

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

Riprodurre gli esempi con plotly.express.scatter, iniziando dalla gestione degli argomenti y e error_y. Confrontare il modo in cui vengono espansi i valori di y simili ad array con il modo in cui viene convalidato error_y. Il lavoro è completato quando è possibile fornire array di errori corrispondenti per ogni serie y senza generare l’errore di lunghezza segnalato e il comportamento rilevante è coperto dai test.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.