Skip to content

Jupyter Plotly JSON mime renderer does not update #3053

Closed

Description

@rapgenic

When displaying some plotly JSON content the viewport does not update on subsequent changes of the data. However closing and reopening the notebook does indeed display the updated plot, suggesting that there might be a problem with the renderer itself.

Example code:

out = {}
out['application/vnd.plotly.v1+json'] = {
    "data": [
        {
            "x": [
                "giraffes",
                "orangutans",
                "monkeys"
            ],
            "y": [
                20,
                14,
                23
            ],
            "type": "bar"
        }
    ]
}
h = display(out, raw=True, display_id=True)
# This does not update the rendered view 
# however closing and reopening the notebook does
out['application/vnd.plotly.v1+json']['data'][0]['y'][0] = 10;
h.update(out, raw=True)

No error is reported in the developer console

Environment:

Output of command jupyter labextension list:

JupyterLab v3.0.6
/usr/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK

Other labextensions (built into JupyterLab)
   app dir: /home/giulio/.jupyter/lab/appdir
        jupyterlab-plotly v4.14.3 enabled OK

Activity

  1. blois commented on May 18, 2021

    @blois

    Investigated googlecolab/colabtools#2020 which appears to be related.

    I believe the root of this is that _ipython_display_ is being used:
    https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/basedatatypes.py#L837

    That method is deprecated, with _repr_mimebundle_ being the preferred:
    https://github.com/ipython/ipython/blob/e37bc7afddaf74327eabf661b4ebd4e1047299b5/IPython/core/formatters.py#L898-L900

    The issue as far as I can see is that _ipython_display_ does not result in a mime bundle with the display ID set on it.

    A simplified example which shows the difference between the two mechanisms with display handles in play:
    https://colab.research.google.com/gist/blois/88002846ca09081bfab1e87b8592717e/custom-display-formatters.ipynb

  2. gvwilson commented on Jun 25, 2024

    @gvwilson
    Contributor

    Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

  3. AllenDowney commented on Nov 2, 2026

    @AllenDowney

    This still happens with jupyterlab-plotly 7.1.0 in JupyterLab 4 (and JupyterLite 0.8), with the example above. The cause is in js/src/mimeExtension.ts: renderModel returns early whenever the widget already has a graph, so an update_display_data never reaches Plotly.react. #5865 redraws when the figure has changed. It also affects the Octave kernel xeus-octave, whose animations stay on their first frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions