Skip to content

Using iplot with ipython.display duplicates widgets in JupyterLab #1516

Description

@manycoding

I created the same issue for ipywidgets jupyter-widgets/ipywidgets#2359 because I am not sure where it belongs.

TL;DR If I plot a graph with plotly iplot, any ipywidgets are duplicated.

The reason why I don't use display() and widgets for both is that widgets are not saved if I close a notebook, and I want the graph output to be available after I reopen a notebook.
So I thought I can plot graphs with plotly.offline.iplot() and widgets with display(), but the former prints any available widget again and again.

import ipywidgets
import plotly.graph_objs as go
from plotly.offline import iplot

data = [go.Bar(x=[i for i in range(5)], y=[i for i in range(5)], orientation="h")]
layout = go.Layout(
    bargap=0.1,
    xaxis=go.layout.XAxis(type="log", title="log"),
    template="ggplot2",
    hovermode="y",
    margin=dict(l=200, t=35),
)
iplot(go.Figure(data, layout))

c = ipywidgets.Checkbox(description="%", value=False)
display(c)

Screenshot 2019-04-04 at 11 24 23

plotly 3.7.1
ipython 7.4.0

JupyterLab v0.35.4
Known labextensions:
app dir: /Users/valery/.local/share/virtualenvs/arche-lm24e12g/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v0.38.1 enabled OK
@jupyterlab/plotly-extension v0.18.2 enabled OK
plotlywidget v0.8.0 enabled OK

iplot_display_dupes.ipynb.zip

Activity

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