Skip to content

FigureWidget missing update for annotations/static lines #4318

Open
@paoloalba

Description

@paoloalba

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions