question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FigureWidget doesn't update in Jupyter Notebook

See original GitHub issue

This snippet in a Python cell produces a chart, but the chart does not update to get the new title and new data.

import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

init_notebook_mode()
data = [go.Bar(
            x=['giraffes', 'orangutans', 'monkeys'],
            y=[20, 14, 23]
    )]
layout = {'yaxis': {'range': [0, 25]}}
fig = go.FigureWidget(data, layout)
iplot(fig)

# The following code is ignored.
fig.data[0].y = (5,10,1)
fig.layout.title = "New title"

Plotly version: 3.5.0 Server Information: You are using Jupyter notebook. The version of the notebook server is: 5.7.4 The server is running on this version of Python: Python 3.7.1 (default, Dec 14 2018, 13:28:58) [Clang 4.0.1 (tags/RELEASE_401/final)]

Current Kernel Information: Python 3.7.1 (default, Dec 14 2018, 13:28:58) Type ‘copyright’, ‘credits’ or ‘license’ for more information IPython 7.2.0 – An enhanced Interactive Python. Type ‘?’ for help.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ubershmekelcommented, Jan 25, 2019

@jonmmease When I do that - nothing is displayed after the cell completes.

2reactions
jonmmeasecommented, Jan 25, 2019

Hi @ubershmekel ,

For the visual display of the FigureWidget to update you need to allow it to display itself as an ipywidget by making the fig variable the last statement in a notebook cell. In particular, you can’t use iplot. For example:

import plotly.graph_objs as go

data = [go.Bar(
            x=['giraffes', 'orangutans', 'monkeys'],
            y=[20, 14, 23]
    )]
layout = {'yaxis': {'range': [0, 25]}}
fig = go.FigureWidget(data, layout)
fig

newplot

# The following code will update the plot above
fig.data[0].y = (5,10,1)
fig.layout.title = "New title"

Does that work for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

FigureWidget doesn't print graph - Plotly Community Forum
Hi All, I have been using plotly for a while and it worked great until i had to use FigureWidget to interact with...
Read more >
Plotly FigureWidgets doesn't get loaded in kaggle's notebook
This seems to be a known bug for the Kaggle Notebooks. I have found multiple posts within the Kaggle Discussion community.
Read more >
Panel plots are not updating from widget inputs
Hi, I'm trying to build a POC app with a map (plotly.choropleth_mapbox) that updates given inputs from widgets (a slider, a text box, ......
Read more >
Ipywidgets and plotly interactions - Jupyter Community Forum
FigureWidget (data=px.scatter(big_grid, x="coord1", y="coord2", ... Basically when i change dromp_elem the color doesn't adjust as i am ...
Read more >
Plotly doesn't work in Ipython Notebooks : PY-18662 - YouTrack
When trying to run init_notebook_mode() for the plotly library in an Ipython Notebook, the cell never completes ( so it shows In[*], and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found