plotly / plotly/plotly.py

FigureWidget missing update for annotations/static lines

Offen
#4,318 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

I use a FigureWidget as container for an updating Figure within JupyterLab. When I update the FigureWidget within a batch_update, the data and the layout overall are updated, but if I introduced a static object like a vline, this persists on the graphic. New executions of the very same FigureWidget instance show the refreshed frame. The properties of the instance itself are also indeed correctly update. Only the old frame in the previous executed cell misses the update on the static lines (but the data and other parts of the layout are correctly update every time as expected).

Here the basic code for reproducing the bug:

import plotly.graph_objects as go
import ipywidgets as wdgt

from plotly import __version__

print(f"Plotly: {__version__}")
print(f"IPywidgets: {wdgt.__version__}")

fig_wdgt = go.FigureWidget()
fig_wdgt

fig = go.Figure()

# fig.add_trace(go.Scatter(x=[1, 2, 3], y=[2, 1, 3]))

# fig.add_vline(x=2, annotation_text="my test line")

with fig_wdgt.batch_update():
    fig_wdgt.data = []
    fig_wdgt.layout = {}

    fig_wdgt.add_traces(fig.data)
    fig_wdgt.layout = fig.layout

and here screenshots with the bug, and suggested use of the code within Jupyter cells:
plotly_screenshot_1

plotly_screenshot_2

I tested the behaviour with python 3.10, Plotly: 5.15.0 and IPywidgets: 8.0.4, on OS, Linux, Windows, and on both Chrome and Edge browsers.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der FigureWidget- und batch_update-Reproduktion aus dem Issue und verwende dabei die angegebenen Versionen von Python, Plotly und ipywidgets in JupyterLab. Vergleiche Aktualisierungen an Daten, Layout und statischen Objekten wie vlines. Als erledigt gilt die Aufgabe, wenn die zuvor ausgeführte Zelle ihre Annotationen und statischen Linien aktualisiert, ohne dass eine erneute Ausführung erforderlich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
jupyter-notebook, python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.