plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

FigureWidget performance problem on Jupyterhub

Open alexcjohnson opened this issue 9 months ago • 2 comments

When I use FigureWidget in v6.0.0 and v6.0.1 in Jupyterhub, even a very simple figure takes about 10 seconds to appear. This is particularly frustrating because it's the default renderer, so for example I see this if I just enter

px.scatter(x=[1,2,3],y=[4,5,6])

and execute the cell. In v5.24.1 the graph appears in about 1 sec. I'm currently in Africa, using a Jupyterhub instance on AWS in us-west-2, so at first I thought the distance may have contributed but a user in Montreal ( @cardinalgeo ) accessing the same instance reports about the same delay. My workaround, in cases where I don't need FigureWidget capabilities, is to change the default renderer:

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

Local Jupyterlab - run either directly in a terminal or via docker - shows no noticeable delay using FigureWidget.

alexcjohnson avatar Apr 15 '25 13:04 alexcjohnson

After https://github.com/plotly/plotly.py/pull/5096 the default behavior is fast, because the default display is a Figure again. But FigureWidget seems to behave the same as it does in 6.0.0 and 6.0.1, which today is: first display of a FigureWidget takes 10-12 sec, subsequent displays take 3-5 seconds. I don't recall seeing this distinction between first and later displays when I first tested this, but both cases are still much slower than a plain Figure.

alexcjohnson avatar Apr 18 '25 06:04 alexcjohnson

@manzt Is it possible that this is related to anywidget?

marthacryan avatar Apr 18 '25 15:04 marthacryan

not able to reproduce - @alexcjohnson is this still a concern for you?

gvwilson avatar Jun 17 '25 16:06 gvwilson

I've had inconsistent results trying to reproduce this myself - may be something strange going on in my Jupyter env. We can close this and I'll reopen if I find a clear pattern.

alexcjohnson avatar Jun 18 '25 13:06 alexcjohnson

thanks @alexcjohnson - much appreciated

gvwilson avatar Jun 18 '25 14:06 gvwilson