Comparing WebGL vs SVG in Python/v3

Comparing WebGL with Scattergl() to SVG with Scatter() in Python with Plotly.


Note: this page is part of the documentation for version 3 of Plotly.py, which is not the most recent version.
See our Version 4 Migration Guide for information about how to upgrade.

Comparing Scatter Plots with 75,000 Random Points

Now in Ploty you can implement WebGL with Scattergl() in place of Scatter()
for increased speed, improved interactivity, and the ability to plot even more data!

WebGL

In [1]:
import plotly.plotly as py
import plotly.graph_objs as go

import numpy as np

N = 75000
trace = go.Scattergl(
    x = np.random.randn(N),
    y = np.random.randn(N),
    mode = 'markers',
    marker = dict(
        line = dict(
            width = 1,
            color = '#404040')
    )
)
data = [trace]
layout = dict(title = 'WEBGL')
fig = dict(data=data, layout=layout)
py.iplot(data, filename='webgl75')
Out[1]:

SVG

In [2]:
import plotly.plotly as py
import plotly.graph_objs as go

import numpy as np

N = 75000
trace = go.Scatter(
    x = np.random.randn(N),
    y = np.random.randn(N),
    mode = 'markers',
    marker = dict(
        line = dict(
            width = 1,
            color = '#404040')
    )
)
data = [trace]
layout = dict(title = 'SVG')
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='svg75')
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/plotly/plotly.py:236: UserWarning:

Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions:
(1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph.
(2) Trying using the image API to return an image instead of a graph URL
(3) Use matplotlib
(4) See if you can create your visualization with fewer data points

If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning.

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/plotly/plotly.py:1441: UserWarning:

Estimated Draw Time Too Long

The draw time for this plot will be slow for all clients.
Out[2]:

References