Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Plotly JSON mime renderer does not update #3053

Closed
rapgenic opened this issue Jan 29, 2021 · 2 comments
Closed

Jupyter Plotly JSON mime renderer does not update #3053

rapgenic opened this issue Jan 29, 2021 · 2 comments

Comments

@rapgenic
Copy link

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
@blois
Copy link

blois commented May 18, 2021

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

@gvwilson
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants