Extra_y_ranges appears to be slow

I am making a real-time time series plot of a lot of variables ( ~200). Initially I set visible to false for all the lines. I have LinearAxis created also for each variable. Again these are initially hidden. The user can make the lines and axes visible through a JS callback. This all works well. The issue is that it is slow. There might be other issues that make it slow but one thing that is definitely slow is p.extra_y_ranges. I am updating all of them each time new data comes in. If I comment out the line that does that, things speed up a lot.

In writing this, I guess I could just update the ones that are visible.

I am surprised this takes so long but I don’t really know all that it needs to do.

Or am I missing something else? Any advice?

Thanks in advance.

The issue is that as new data comes in, I update

In general it’s not really possible to say anything specific at all without a complete Minimal Reproducible Example to so that actual code can be inspected and run and investigated, if necessary.

For instance, are you saying you have 200+ axes added to your plot? That’s two orders of magnitude more than I’ve ever heard of anyone trying, or that I had in mind when “twin axes” support was originally added. If that is what you mean, then I think your idea to “just update the ones that are visible” is the appropriate course of action.

Hi @Bryan thanks for the response. Sorry for not providing an MRE. I really just wanted some feedback letting me know that what I was doing actually should take long so I know what limitations I might have. I did just update the visible ones. That solved my speed problem completely.

So I actually do create 200 axes on the python side but initially make the invisible. This is a little slow but it is a one time thing, so not that bad for the user. ( 30 seconds now). Then on the javascript side, they are made visible as the user selects variables to plot. The user will probably never select more 6 variables to plot. One of them is always on the left side.

So I think I am good. Thanks again.

@Bryan I wanted to follow up again. It turns out that none of my slowness in my app was due to Bokeh. It was all in my data layer code. So I am really impressed with how well Bokeh is handling so many lines, axes…

1 Like