go.Scatter vs go.Scattergl

Hi there,

I was wondering if there was any kind of guidance on when to use go.Scatter and when to use go.Scattergl? Is there a cutoff of number of data points when one is better than the other? Any other consideration on choosing on or the other? Or just try and see?

(I’d like to automatically choose the right one for my explainerdashboard package where users can pass any size dataset, large or small, so I need to automate the choice)

1 Like

If you don’t need the features of Scatter, I am not sure why you couldn’t just use Scattergl for any number of data points? :upside_down_face:

If you have more than 10 000 data points over time for example Scattergl is a lot faster and more responsive in my experience.

So scattergl is basically always faster (but may lack some features)?

Is there any sample size for which it would be actually slower?

I don’t know.

#######

That’s my impression. But if you are unsure, you could test it out with a few indicative samples sizes (1e1, 1e2, 1e3, 1e4, 1e5, …).

scattergl is faster but it’s rendered with webgl instead of svg. svg are vector graphics and so they look better when exported. some journals, publications, and websites will only publish vector graphics. also, some small portion of web users are on web browsers or computers that don’t have a gpu or have disabled webgl for security reasons.

2 Likes

you will definitely notice a difference around 10k points. there are fundamental limits with svg and the number of elements that can be rendered to the DOM, so anything above 20k points is pretty slow / technically impossible to render with svg. that’s why we rewrote some of these chart types in webgl :slight_smile:

2 Likes

Okay, so summary:

  • go.Scattergl is basically always faster but you really start seeing the difference around 10.000 datapoints.

Other considerations:

  • go.Scattergl has a few feature missing compared to go.Scatter so depending on your particular plot may not work as well.
  • go.Scattergl does not output vector graphics, so don’t use your dashboard to make graphics for your academic paper :slight_smile:
  • Some older web browsers may not support WebGL yet.

Thanks!

1 Like

The only downside I found of using go.Scattergl is that the browser may have a limit of GL contexts that it can display at once. See this issue. You may get it to work on Chrome by launching the app from the command line with the --max-active-webgl-contexts argument to specify explicitly the maximum number of WebGL contexts, but it’s definitely less convenient. But if you stick to 8 graphs or less on the same page, you should not run into that issue.

1 Like

Great point, thanks for sharing that limitation @potard!