Unable to open a Plotly image

Usually you want your code to be a minimal reproducible example. In this case it isn’t even syntactically correct and gives a syntax error even if I remove the incomplete line hover_name=[(...)],.

To give us more of a basis to discuss what is not happening for you…if I go here and launch a session where Ploty is installed via the launch binder badge I currently get Plotly version 5.24.1 running in JupyterLab 4.2.5 presently.

And run the following example that Google Gemini gave me for Plotly pio:

import plotly.io as pio
import plotly.graph_objects as go

# Create a figure
fig = go.Figure(data=[go.Bar(y=[2, 1, 3])], layout_title_text="A Figure Displayed with pio.show()")

# Display the figure using pio.show()
pio.show(fig)

I got a plot.

If I right-click on the text ‘A Figure Displayed with pio.show()’ in the output area, I see JupyterLab’s context dependent menu come up.

You seem to want to do something with pio.renderers, yet don’t mention that in the text of the post or title (see section below)?

If I run the following as spelled out here:

import plotly.io as pio
pio.renderers

I don’t see iframe as choice in what comes up from running that. I saw 'iframe_connected'. So first I’ll tried to use that. (Then later I read more about just ‘iframethere and it worked the similar as 'iframe_connected', in this test, with the HTML being more with ‘iframe’ so that it is more self-contained.)

Now when I restart the kernel and run the following, I get something slightly different:

import plotly.io as pio
pio.renderers.default = 'iframe_connected' #'iframe' works, too. See above.
import plotly.io as pio
import plotly.graph_objects as go

# Create a figure
fig = go.Figure(data=[go.Bar(y=[2, 1, 3])], layout_title_text="A Figure Displayed with pio.show()")

# Display the figure using pio.show()
pio.show(fig)

I get a plot that looks a bit bigger (taller) than the one I first got and I note that the behavior is different.
I can right-click on the text ‘A Figure Displayed with pio.show()’ in the output area and now I get a different menu and it has the option ‘This Frame’ with more sub options, such as ‘Open Frame in New Window’ and when choose that it gives me a new window showing the plot filling it. If back in JupyterLab, I right-click on the title text and choose ‘This Frame’ > ‘View Frame Source’ it seems to show HTML that indicates I am seeing an iframe.

I am using Firefox on my Mac.


The title and the first line are confusing? An ‘image’ or a plot figure? Images usually mean binary image buffer or file of defined formats or like a raster. I think you mean Plotly figure objects/plots?

2 Likes