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 does work not from inside an if statement

See original GitHub issue

Encountered in Jupyter Lab.

Take the following 2 cases:

fig = go.FigureWidget()
fig

&

silent=False

if not silent:
    fig = go.FigureWidget()
    fig

The first one produces a figure, the second one does not. Why don’t they behave similarly?

If I use the @interact decorator in the second case. e.g.

if not silent:
    fig = go.FigureWidget()
    fig.add_scatter()

    @interact(s=(3,5))
    def update(s=3):
        with fig.batch_update():
            fig.data[0].y = np.random.normal(size=s)
    fig

the slider appears, but the figure does not.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jasongroutcommented, Nov 4, 2019

display is what IPython calls automatically on the last top-level expression to display it in your first example.

1reaction
jasongroutcommented, Nov 4, 2019

You may be able to use the display command:

if True:
    fig = go.Figure()
    display(fig)

(if you have an older version of ipython, you may need to import it: from IPython.display import display

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plotly figurewidget overview in Python
Construct a FigureWidget from a Figure graph object¶. A standard Figure object can be passed to the FigureWidget constructor.
Read more >
plotly's FigureWidget does not respect display order when ...
Before getting that far, I am unable to get the images displayed correctly inside jupyterlab together with ipywidgets.
Read more >
Could we have Plotly FigureWidget support? - Streamlit
I want to use Streamlit instead (else Panel), but a requirement I have is interactions between plots - so selecting an area of...
Read more >
Supercharge your Python plots with zero extra code!
The importance of plotting in a data scientist's work cannot be overstated. ... If you have worked on any kind of data analysis...
Read more >
How to make multi-index index charts with Plotly
While regular index charts work fine, by using a simple extension to ... If you care about only one of the three charts...
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