0

Background

  • I'm working on a data challenge with 3GB data.
  • I plotted about 10 plots using ploy-express in jupyter notebook.
  • I didn't use fig.show('notebook') because it didn't work.
  • I used py.init_notebook_mode(), all plots show up perfectly in notebook.
  • They are simple plots each with 1 year of data, like fig = px.line(df, x, y, ...) then fig.show()

Everything works fine in notebook.

Problem

But until I tried to convert notebook into HTML file, only the latest 6 plots show up.

The first 4 plots have titles, legends, axes, background-canvas, when I hover over them the numbers pop up, but plots are not showing up, and each has an unhappy square face with "x"-looking eyes.

I tried:

  • !jupyter nbconvert notebook.ipynb --to html --template classic
  • or with --execute
  • or without --template
  • I increased notebook size changing NotebookApp.max_buffer_size, this didn't work.

I suspect this is a memory limit problem on nbconvert or HTML-related, because:

Did anyone solve the same problem? Could someone help please?

Not Perfect Solution

  • I have to click the legend then it shows up.
  • But another graph disappears again.
  • The total available is always 6 graphs like there is a limit of something
Byron
  • 59
  • 7

2 Answers2

0

Accidentally, I found out the all plots show up when I use Firefox, so I realize this is a render problem.

It turns out the default is WegGL, and I switched to SVG, by adding render_mode='svg'.

Wala, everything is solved.

BigBen
  • 46,229
  • 7
  • 24
  • 40
Byron
  • 59
  • 7
  • 1
    This looks like a useful answer. Could you please clarify where you added `render_mode='svg'`? Could you show the full command / code? – edesz Jan 12 '22 at 20:01
0

Just open the notebook in Jupyter-lab. From File menu select the option to export as HTML. It worked for me. I haven't found a way to make it work with nbconvert from command line. It would be good that you provide how you used render_mode='svg'. In my approach images were reduced and their java script was lost.

LeninGF
  • 332
  • 3
  • 10