# go.Scatter vs go.Scattergl

**URL:** <https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617>\
**Category:** Dash Python\
**Created:** [November 26, 2020, 7:01pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617 "2020-11-26T19:01:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![oegedijk](https://avatars.discourse-cdn.com/v4/letter/o/a88e57/32.png) [@oegedijk](https://community.plotly.com/u/oegedijk)\
**Post date:** [November 26, 2020, 7:01pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/1 "2020-11-26T19:01:26Z")

</div>

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](https://github.com/oegedijk/explainerdashboard) package where users can pass any size dataset, large or small, so I need to automate the choice)

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [November 26, 2020, 7:38pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/2 "2020-11-26T19:38:03Z")

</div>

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? 🙃

---

<div class="post-metadata">

**Author:** ![windrose](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/windrose/32/13691_2.png) [@windrose](https://community.plotly.com/u/windrose)\
**Post date:** [November 26, 2020, 8:41pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/3 "2020-11-26T20:41:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![oegedijk](https://avatars.discourse-cdn.com/v4/letter/o/a88e57/32.png) [@oegedijk](https://community.plotly.com/u/oegedijk)\
**Post date:** [November 27, 2020, 12:24pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/4 "2020-11-27T12:24:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![oegedijk](https://avatars.discourse-cdn.com/v4/letter/o/a88e57/32.png) [@oegedijk](https://community.plotly.com/u/oegedijk)\
**Post date:** [November 27, 2020, 12:24pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/5 "2020-11-27T12:24:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![windrose](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/windrose/32/13691_2.png) [@windrose](https://community.plotly.com/u/windrose)\
**Post date:** [November 27, 2020, 12:26pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/6 "2020-11-27T12:26:00Z")

</div>

I don’t know.

#######

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [November 27, 2020, 12:39pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/7 "2020-11-27T12:39:01Z")

</div>

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, …).

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [November 27, 2020, 1:11pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/8 "2020-11-27T13:11:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [November 27, 2020, 1:13pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/9 "2020-11-27T13:13:20Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![oegedijk](https://avatars.discourse-cdn.com/v4/letter/o/a88e57/32.png) [@oegedijk](https://community.plotly.com/u/oegedijk)\
**Post date:** [November 27, 2020, 1:20pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/10 "2020-11-27T13:20:11Z")

</div>

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 🙂
- Some older web browsers may not support WebGL yet.

Thanks!

---

<div class="post-metadata">

**Author:** ![potard](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@potard](https://community.plotly.com/u/potard)\
**Post date:** [December 2, 2020, 9:05pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/11 "2020-12-02T21:05:50Z")

</div>

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](https://community.plotly.com/t/scattergl-markers-not-displaying/19553). 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.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [December 3, 2020, 7:42pm UTC](https://community.plotly.com/t/go-scatter-vs-go-scattergl/47617/12 "2020-12-03T19:42:09Z")

</div>

Great point, thanks for sharing that limitation @potard!
