Blank output in Jupyter

I have installed plotly into a new Jupyter environment in mamba. When I attempt to run an example program from the plotly webpage within Jupyter, a blank output cell is created, but no graphics are visible. Taking an example from the gallery on plotly as shown below and running it in Jupyter results in a blank cell being created. Changing the last line from fig.show() to fig.show(renderer=β€˜iframe’) (as suggest by someone using Google search results in what appears to be the correct (interactive) graphic output. What is going on and how can I fix this problem. Note the person who gave the suggestion I referenced had no idea why it worked either, although he mentioned that several different renderer options worked as well as β€˜iframe’

import plotly.graph_objects as go
import numpy as np
X, Y, Z = np.mgrid[-8:8:40j, -8:8:40j, -8:8:40j]
values = np.sin(X*Y*Z) / (X*Y*Z)

fig = go.Figure(data=go.Volume(
    x=X.flatten(),
    y=Y.flatten(),
    z=Z.flatten(),
    value=values.flatten(),
    isomin=0.1,
    isomax=0.8,
    opacity=0.1, # needs to be small to see through all surfaces
    surface_count=17, # needs to be a large number for good volume rendering
    ))
fig.show()
1 Like

Hey @ welcome to the forums.

What about a simple figure? Does this render?

import plotly.graph_objects as go

fig = go.Figure(
    data=go.Scatter(
        x=[1, 2, 3], 
        y=[1, 2, 3],
        mode='markers+lines'
    )
)

fig.show()

I have also been dealing with this problem. I am using conda environments with notebook 7.0.6 and plotly 5.18.0. I am installing notebooks in my base env, and managing kernels with nb_conda_kernels

I have installed this same setup on two different machines, both of which produce only empty space where the figure is supposed to be. In both cases, setting pio.renderers.default = 'iframe' is the only way to produce figures inline.

I have a third computer which has the same setup but uses notebook 6.5.3 and plotly 5.15.0, and figures render fine automatically.

I suspect the recent releases of Jupyterlab 4 and Notebook 7 have broken something.

1 Like