VS code not showing plotly figures in notebook after closing and reopening it

So I’d like to know how to enable VS Code to open plotly figures on a jupyter notebook when opening one.

When loading a notebook that already contains figures in it with jupyter, the images display normally, but in VS Code there are blank spaces instead. I need to re-run all notebook cells for the figures to be displayed again.

I’m running the notebook with the command pio.renderers.default = 'notebook' and displaying the figures with fig.show().

How to fix this ?


Welcome to the community! :slight_smile:

I haven’t seen this issue before, so I ran a quick check and I cannot reproduce this error when using “plotly_mimetype” or “plotly_mimetype+notebook”. The second one seems to be the default set by the jupyter extension.

Could you try to change the renderer from “notebook” to one of these two and see if it works?

Hello, thank you for your suggestion. Unfortunately, the problem persists.

I get this error on both my machines, both running on Ubuntu 20.04.

For the note, I was using ‘notebook’ as a renderer because it is important to me that the images can be rendered while offline.

Ok, my test was on Mac, and this could be OS-related.

I would recommend you to raise an issue on vscode-jupyter GH repo if you haven’t done it yet.

Will do, thank you.