Plotly - notebook / Very slow render with many graphs

I’m wondering if anyone else is seeing this behaviour as well as:
Is this a plotly thing or a jupyter notebook thing or a mix of both?

I am iteratively creating graphs with relatively modest sized datasets (At most 150 rows). It’s all summary data, 3-5 columns * up to 150 rows.

After about 3-4 graphs created in a given page the rendering takes a huge hit in terms of speed. The page seems to freeze up and with 15+ graphs on a given notebook it can take up to 20 minutes to fully render, once it is fully rendered it’s reasonably performant (other than being very slow to switch tabs).

using https://hub.docker.com/r/jupyter/all-spark-notebook/tags/ on latest I think that’s (14fdfbf9cfc1)

And plotly version: @jupyterlab/plotly-extension v0.18.1

root@47712b0e71c0:~# jupyter --version
4.4.0

root@47712b0e71c0:~# jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v0.38.1  enabled  OK
        @jupyterlab/hub-extension v0.12.0  enabled  OK
        @jupyterlab/plotly-extension v0.18.1  enabled  OK
        jupyterlab_bokeh v0.6.3  enabled  OK

I’m mostly wondering if my use case (multiple distinctly drawn graphs in one notebook is a common or extreme edge case. And really, is anyone else seeing this or just me?

Hi @garylucas,

Just out of curiosity, could you try out your notebook in the classic Jupyter notebook (rather than JupyterLab), and see if the same performance issues are present? You’ll need to run plotly.offline.init_notebook_mode() once before displaying plots with plotly.offline.iplot.

-Jon

I got some feedback here: https://github.com/jupyterlab/jupyter-renderers/issues/171 and it looks like it may be specific to that jupyter extension.

When I have some spare time I’ll create something I can share that demonstrates the issue.

Thanks for digging into this @garylucas, any observations you come away with would be appreciated!
-Jon

Hi,

This is not an isolated problem, I’m also facing it in Jupyter Lab but not in Jupyter Notebook. I will try to take a look, but I’m not familiar with the extension code.

Diogo Pinto

This is happening for me too. Is there any known resolution? I really like the Jupyter Lab interface, but it’s unusable once I start creating notebooks with multiple plotly graph objects.

Hi all,

I’m working on a big refactor of the plotly.py rendering subsystem in https://github.com/plotly/plotly.py/pull/1474, and one of the new renderers is going to be an iframe renderer that stores each figure as a separate HTML file in a directory next to the notebook and then inserts an iframe in the notebook that references the HTML file.

I would appreciate it if some folks who have notebooks that are bogging down JupyterLab could give this branch a try (installation instructions https://github.com/plotly/plotly.py/pull/1474#issuecomment-476663406) and report back on whether the iframe renderer improves responsiveness. To use the iframe renderer on this branch, don’t call init_notebook_mode(), but do call…

import plotly.io as pio
pio.renderers.default = 'iframe'

once at the top of the notebook before displaying figure with iplot.

One limitation of the iframe renderer to be aware of is that doesn’t support responsive resizing. As of 3.8.1 the iframe renderer supports resizing.

Thanks,
-Jon

1 Like

@jmmease Will this also effect the responsiveness of updated figurewidgets?

Hi @Varlor, no, this will only be for the rendering of standard Figure objects.
-Jon

Hi all, I’m wondering if there is a solution to a similar problem I’m having with hosting my app on a webpage (not through Jupyter notebooks). Creating the plots behind the scene happens very quickly (under 10 seconds), but it takes my browser at least 1-2 minutes just to render the plots, which takes away from UX of course. I’ve been trying to scroll through the forum and while some suggestions point to Scattergl, that didn’t help much while generating multiple plots. My plots are currently all standard Figure objects, specifically Scatter plots.

I have some more details here : How to efficiently render many (70+) plots

Does anybody have any ideas on how to lower the amount of time it takes for the browser to render the plots? Maybe showing them as they generate instead of all at once?

it’s better than before, but still there is lag.

1 Like

yep I’m still having this challenge today with a bar chart figure

Hi, do you still have these details somewhere? It appears that the thread about efficiently rendering many plots has been deleted.