Static plots in Jupyter envs

At this moment, is this the optimal way of producing static plots in Jupyter Labs with plotly:

import numpy as np

import plotly.graph_objs as go
import as pio
from IPython.display import Image
fig = go.FigureWidget()

img_bytes = pio.to_image(fig, format='png', width=600, height=350, scale=20)
Image(img_bytes, width=600, height=350)

or is it possible to achieve the same simply by passing some argument somewhere?


At the moment, I think this is the way to do it indeed.
Another way to do it: If you’re using nbconvert to convert your notebook to LaTeX for example (HTML works similarly I think), the plotly figures will be automatically converted to PNG.

I tag @jmmease; His rework on the renderers ( was merged a few days ago into the master branch. With the new renderers, it will be possible to do static plots by passing an argument.


Thanks @GorgiAstro,

Yes, when 3.8.0 is released (any day now :slightly_smiling_face:), you could do this with the new renderers subsystem. In particular:

import as pio
pio.renderers.default = 'png'

fig = ...

You can try out version 3.8.0rc1 if you’d like to give it a spin now. See for instructions.


1 Like