WebGL vs SVG in Python

Implement WebGL for increased speed, improved interactivity, and the ability to plot even more data!


New to Plotly?

Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

Here we show that it is possible to represent millions of points with WebGL. For larger datasets, or for a clearer visualization of the density of points, it is also possible to use datashader.

Compare WebGL and SVG

Checkout this notebook to compare WebGL and SVG scatter plots with 75,000 random data points

WebGL with Plotly Express

The rendermode argument to supported Plotly Express functions can be used to enable WebGL rendering.

Here is an example that creates a 100,000 point scatter plot using Plotly Express with WebGL rendering enabled.

In [1]:
import plotly.express as px

import pandas as pd
import numpy as np
np.random.seed(1)

N = 100000

df = pd.DataFrame(dict(x=np.random.randn(N),
                       y=np.random.randn(N)))

fig = px.scatter(df, x="x", y="y", render_mode='webgl')

fig.update_traces(marker_line=dict(width=1, color='DarkSlateGray'))

fig.show()