plotly / plotly/plotly.py

When calling update_layout() on a figure, xaxis_range does not update correctly when margin_b is specified

Aperta
#5,106 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

plotly                    6.0.1

I create a figure like so

fig = go.Figure()
fig.add_trace(go.Scatter(x=np.arange(100), y=np.arange(100)))
fig.update_layout(xaxis_range=[50,None])
# fig.update_layout(margin_b=20)
fig.show()

Expected behavior
fig.update_layout(xaxis_range=[50,None]) (Line 3) should set the min xaxis value to be 50, while keeping the max value intact. It does this correctly (Correct: x-axis is from 50 to 100). Interestingly, when I click the modebar to download the plot as png, the xaxis range is incorrect in the output image.

Image

Bug
If you uncomment the line fig.update_layout(margin_b=20) (Line 4) which adjusts the bottom margin, the x axis range is back to its original value unaffected by Line 3 (Inorrect: x-axis is from 0 to 100). Interestingly, if you double click the plot to reset the axes, the x axis changes to the updated value (50 to 100).

Image

Note:
Weirdly, if I change Line 3 to fig.update_layout(xaxis_range=[50,100]) (specify 100 instead of None) and keep the margin_b line uncommented, the behavior is correct again.

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 eseguendo l’esempio Python minimo usando update_layout() e confronta margin_b=20 con un massimo esplicito di xaxis_range e con None. Il report non indica alcun file sorgente né alcun test; il lavoro è completato quando l’asse x rimane da 50 a 100 nel grafico interattivo e nel PNG scaricato quando il margine inferiore è impostato.

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à
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.