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

Plotly widgets do not work #19

Closed
blois opened this issue Nov 22, 2021 · 5 comments
Closed

Plotly widgets do not work #19

blois opened this issue Nov 22, 2021 · 5 comments

Comments

@blois
Copy link
Collaborator

blois commented Nov 22, 2021

From googlecolab/colabtools#498 (comment)

from google.colab.output import _widgets
_widgets._install_custom_widget_manager('http://127.0.0.1:9897/manager.dev.js')

import plotly.graph_objects as go
f = go.FigureWidget(layout={'height': 400, 'width': 400})
display(f)

The issue is that the current version (1.4.0) targets Phosphor and relies on processPhosphorMessage being called:
https://github.com/plotly/plotly.py/blob/df19fc702b309586cc24e25373b87e8bdbb3ff60/packages/javascript/jupyterlab-plotly/src/Figure.ts#L907

This package currently targets widgets 5.0.0 which has not yet had a stable release. In 5.0 Phosphor was renamed to Lumino and all related methods were renamed as well. See jupyter-widgets/ipywidgets@a558dac.

This is similar to #12.

@blois
Copy link
Collaborator Author

blois commented Nov 24, 2021

The fix for this should now be in production.

The result of the notebook in googlecolab/colabtools#498 (comment)
image

@cardinalgeo
Copy link

cardinalgeo commented Dec 21, 2021

The fix for this should now be in production.

The result of the notebook in googlecolab/colabtools#498 (comment) image

Hi @blois, as your screenshot shows, only the static plot is produced; the widgets that control it do not appear (they only do so when the block is run with g.show() removed).

@kylebarron dug into this a bit here, but my inexperience has prevented me from diving in further, though I'd be happy to dig deeper if you can point me in the right direction. Is the issue something that needs to be addressed on the Colab side, or does it require that I create an issue in the Plotly repo?

@blois
Copy link
Collaborator Author

blois commented Dec 21, 2021

@cardinalgeo I think this is more of a Plotly question, possibly related to https://plotly.com/python/renderers/#setting-the-default-renderer?

Just so I understand with a simpler example, starting with:

from google.colab import output
output.enable_custom_widget_manager()

import plotly.graph_objects as go

f = go.FigureWidget()

There are effectively two mechanisms to display:

# renderer='colab' is the default in Colab, but can be tweaked.
f.show(renderer="colab")

and:

display(f)

In the first, Plotly is returning a combination of HTML & JS which is rendered. But it sounds like you're looking for .show() to return a Widget which will be rendered? I'm not sure what mechanisms Plotly has for that.

I may be misunderstanding this though.

@kylebarron
Copy link

kylebarron commented Dec 24, 2021

From my reading of Plotly's codebase, f.show() renders with an iframe; display(f) is renders the widget. Ref googlecolab/colabtools#498 (comment)

@Yuri-Nassar
Copy link

Hi guys. Any update on this?
I am trying to use the go. Sankey, but it does not show up in the colab (f.show() or display(f) shows nothing).
I use matplotlib in other methods and they work properly.
Is it a problem of plotly to work with widgets on colab?

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

4 participants