plotly / plotly/plotly.py

px.timeline Incorrectly interprets x_end datetimes

Aperta
#3,473 5 commenti 2 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

The px.timeline function incorrectly generates the end times of the bar traces. The end times are placed before the start times.

Python version 3.8.6
Plotly version 5.4

Steps to reproduce:

import datetime
import plotly.express as px
t0 = datetime.datetime.now()
tf = t0 + datetime.timedelta(hours=1)
px.timeline(x_start=[t0], x_end=[tf])

print(t0)
print(tf)

Produces

2021-11-16 12:21:14.800827  # t0
2021-11-16 13:21:14.800827  # tf

The resulting figure is below. Notice that the right edge of the bar is the same as the start time, but the left edge of the bar is something else entirely.
px_timeline_error

The behavior is the same when passing a dataframe and column names. If you generate a scatter plot using the same datetime objects, the output works as expected (shown below).

correct_scatter

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 dal punto di ingresso px.timeline e riproduci il problema con i valori datetime mostrati nel report, confrontando le coordinate della sua traccia a barre con un grafico a dispersione che utilizzi gli stessi valori. Segui come x_start e x_end vengono convertiti nella figura, quindi verifica che la barra generata abbia gli orari di inizio e fine previsti e che anche il caso dataframe-and-column-names si comporti correttamente.

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

Valutazione

Stack tecnologico
python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.